Contents

Restore Heroku Postgres Database Locally


It would be nice to operate against the same set of data on your local machine with your heroku postgres server. Heroku made this a breeze.

Create a new backup on heroku

1
heroku pg:backups:cature
Note
Use --app <appname> to specify which app to backup. By default, backup operates against primary database, identified by the DATABASE_URL config var. Append database name in the end to choose which database to backup.

Download backup file

Use following command to download latest backup file. The default name is latest.dump.

1
heroku pg:backups:download

Restore backup

Once latest.dump file is download to current file. You can use it to retore to your local postgre database.

1
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d <db name> latest.dump