How to export Heroku Postgres Database to Localhost Database (Rails)?
$ 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
$ pg_restore -O -d YOUR_DATABASE_NAME_HERE latest.dump
$ rake db:migrate
OR
$ rake db:drop db:create; pg_restore -O -d YOUR_DATABASE_NAME_HERE latest.dump; rake db:migrate
heroku pg:backups restore `heroku pg:backups public-url --app production-app-name` DATABASE --app staging-app-name