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
heroku pg:backups:cature
Use
--app <appname>
to specify which app to backup. By default, backup operates against primary database, identified by theDATABASE_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
.
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.
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d <db name> latest.dump