Saturday 27 May 2017

Export and import database from heroku

Export
heroku pg:backups capture
curl -o latest.dump `heroku pg:backups public-url`

Import
heroku pg:backups capture
heroku pg:backups restore 'http://example.herokuapp.com/latest.dump' DATABASE_URL

Export specific Table Heroku
pg_dump --no-acl --no-owner -h ec2-ip.compute-.amazonaws.com -U mdvxormgnpnmne -t events --data-only d3irvpu7la5kcd > events1.dump

Import specific Table Heroku
psql -U postgres -d event-kit_development -f events1.dump

Export Db: 
pg_dump -U {user-name} {source_db} -f {dumpfilename.sql}

Import Db:
psql -U {user-name} -d {desintation_db}-f {dumpfilename.sql}



Dump only contents of db:
backup: 
pg_dump -Fc -v -f full.dump -U postgres dbname
restore: 

pg_restore -a -U postgres -d event-kit_development -Fc full.dump



pg_dumpall -g -U postgres > globals.sql
Dump schema of database:
pg_dump -Fp -s -v -f db-schema.sql -U postgres dbname
Dump contents of database:
pg_dump -Fc -v -f full.dump -U postgres dbname
Now restore.
psql -f globals.sql
psql -f db-schema.sql dbname
pg_restore -a -d dbname -Fc full.dump

No comments:

Post a Comment

Revert last commit or second last and more....

 Git revert commit_id -m 1 this command willl revert last commit  Git revert commit_id -m 2 this command will revert second commit with same...