Easily build a great vocabulary without studying! Now on the App Store!
Click here for more info about the app

How To Create a Dump File in Postgres Compatible with Heroku


When Heroku creates a dump file of your Postgres database it uses the -Fc option

It is equivalent to running

pg_dump -Fc -d name_of_db > name_of_db.dump

This command will let you import your database with the pg_restore command

pg_restore -d name_of_database name_of_db.dump

If you use pg_dump without the -Fc flag you will have to cat the contents of the file to psql

pg_dump -d name_of_db > name_of_db.dump
cat name_of_db.dump | psql name_of_db

This approach is just executing SQL statements. Whereas the former approach is better for working with larger databases that benefit from compressing the file size.

Tagged w/ #postgres #dba #backup #import #export #command line #database