Heroku : PostGreSQL : Dump production / staging database to localhost

$ heroku pg:backups capture -a app_name

this will be echoed in your screen

curl -oUse Ctrl-C at any time to stop monitoring progress; the backup
will continue running. Use heroku pg:backups info to check progress.
Stop a running backup with heroku pg:backups cancel.
DATABASE ---backup---> b001
Backup completed


then you need to download the dump using curl

$ curl -o latest.dump `heroku pg:backups public-url -a app_name`


then create a database in PG and make the dump import to that database

$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U [username] -d [database name] latest.dump
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U john -d new_dump_database_name latest.dump
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U john -d production-dump prod

now config Rails’s Database.yml

  <<: *default
  #  database: rails-app_development
  database: new_dump_database_name



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s