Restore Heroku Postgres Database Locally

Contents

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.

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.

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

1
heroku pg:backups:download

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