Our Blog

Ongoing observations by End Point people

Heroku: dumping production database to staging

By Marina Lohova · June 17, 2015

Tags: database, heroku

If you need to dump the production database locally Heroku has a nice set of tools to make this as smooth as humanly possible. In short, remember these two magic words: pg:pull and pg:push. This article details the process https://devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull

However, when I first tried it I had to resolved few issues.

My first problem was:

pg:pull not found

To fix this:

  1. Uninstall the 'heroku' gem with
gem uninstall heroku (Select 'All Versions')
  1. Find your Ruby 'bin' path by running
gem env


  1. Cd to the 'bin' folder.

  2. Remove the Heroku executable with

rm heroku
  1. Restart your shell (close Terminal tab and re-open)

  2. Type

heroku version

you should now see something like:

heroku-toolbelt/2.33.1 (x86_64-darwin10.8.0) ruby/1.9.3

Now you can proceed with the transfer:

  1. Type
heroku config --app production-app

Note the DATABASE_URL, for example let's imagine that the production database url is HEROKU_POSTGRESQL_KANYE_URL, and the staging database url is HEROKU_POSTGRESQL_NORTH

  1. Run
heroku pg:pull HEROKU_POSTGRESQL_KANYE rtwtransferdb --app production-app
heroku config --app staging-app
heroku pg:push rtwtransferdb HEROKU_POSTGRESQL_NORTH --app rtwtest

This is when I hit the second problem:

database is not empty

I fixed it by doing:


Happy database dumping!