$ cd /path/to/your/rails/app
$ heroku pg:backups capture
$ curl -o latest.dump `heroku pg:backups public-url`
OR
$ curl -o latest.dump `heroku pg:backups public-url --remote <your_remote_name>`
Enter app/config/database.yml
. Copy your localhost database name.
Example:
development:
adapter: postgresql
database: YOUR_DATABASE_NAME_HERE
pool: 5
timeout: 5000
$ rake db:drop db:create db:migrate
$ pg_restore -O -d YOUR_DATABASE_NAME_HERE -c -n public -v latest.dump
OR
$ rake db:drop db:create db:migrate && pg_restore -O -d YOUR_DATABASE_NAME_HERE -c -n public -v latest.dump
heroku pg:backups restore `heroku pg:backups public-url --app production-app-name` DATABASE --app staging-app-name