Postgres copy Heroku Production DB to local development DB Postgres copy Heroku Production DB to local development DB database database

Postgres copy Heroku Production DB to local development DB


Use heroku's "pg:pull":

You'll need to clear your local DB:

rake db:drop

Then collect some information from Heroku:

heroku pg:pull DATABASE_URL test_development

This will connect to the heroku DB, and copy it to the local database.

See Heroku's documentation on pg:pull for more details.


clean your local database:

rake db:schema:load

dump your heroku database:

heroku pg:backups:capture -r <**your production git repo name**>heroku pg:backups:download -r <**your production git repo name**>

load data in your local database

pg_restore --verbose --clean --no-acl --no-owner -h localhost -d <**test database name**> latest.dump


This command should do the work:

heroku pg:pull DATABASE_URL database-name --app heroku-app-name