Skip to content

Instantly share code, notes, and snippets.

@kagemusha
Created January 6, 2012 09:20
Show Gist options
  • Save kagemusha/1569836 to your computer and use it in GitHub Desktop.
Save kagemusha/1569836 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 pgbackups:capture
2. heroku pgbackups:url <backup_num> #=>backup_url
- get backup_num with cmd "heroku pgbackups"
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)
@Schwad
Copy link

Schwad commented Sep 22, 2017

And heroku pg:backups

@0xGerard
Copy link

thanks!

@MeherajUlMahmmud
Copy link

Been searching around and trying out different commands for 2 hours. Finally, your gist helped me do it. Thanks a ton.

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