Make Postgres dump from Heroku human-readable

Posted . Visible to the public.

When dumping your Heroku Postgre database (with heroku pg:backups:capture --app my-app and heroku pg:backups:download --app my-app), it will result in a binary dump.
If you want your contents to be human-readable (e.g. for moving to a different database system like MariaDB or SQLite), you can transform the file with pg_restore:

pg_restore -f output.sql infile.dump

Note that there is also a flag to omit the schema and output only the data of the dump: --data-only. This may be useful if you can restore the schema otherwise, e.g. when using Rails, through running your migrations. When moving to a different RDBMS, this can come handy because you don't have to convert the column datatypes in the file.

Judith Roth
Last edit
Judith Roth
Keywords
Postgresql, migrate, MySQL
Posted by Judith Roth to Judith's Dev Notes (2022-09-24 06:43)