Skip to content

Instantly share code, notes, and snippets.

@wwerner
Forked from kagemusha/gist:1569836
Last active June 20, 2018 10:35
Show Gist options
  • Save wwerner/dd8435676a358cff40edbde883a4392a to your computer and use it in GitHub Desktop.
Save wwerner/dd8435676a358cff40edbde883a4392a to your computer and use it in GitHub Desktop.
Dump Heroku Postgres DB and load locally into postgres
Get the Heroku db as detailed here:
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup
$ heroku pg:backups:capture # outputs backup_num in the last line
$ heroku pg:backups:url <backup_num> #=> backup_url
$ curl -o /tmp/latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb /tmp/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