Skip to content

Instantly share code, notes, and snippets.

@ivan-leschinsky
Forked from kagemusha/gist:1569836
Last active October 30, 2017 20:09
Show Gist options
  • Select an option

  • Save ivan-leschinsky/541ddfeb0a06028a47c2dd307c53b8ba to your computer and use it in GitHub Desktop.

Select an option

Save ivan-leschinsky/541ddfeb0a06028a47c2dd307c53b8ba to your computer and use it in GitHub Desktop.
Dump Heroku Postgres DB and load locally

Get the Heroku db as detailed here: http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup

  1. heroku pg:backups:capture # => b001
  2. heroku pg:backups:url <backup_num> # => backup_url
    • get backup_num with cmd "heroku pg:backups" or with previous command
  3. curl -o latest.dump <backup_url>

Then locally do:

$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump

(your database must exist before can do this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment