Created
January 6, 2012 09:20
-
-
Save kagemusha/1569836 to your computer and use it in GitHub Desktop.
Dump Heroku Postgres DB and load locally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Cheers mate.
Worked great!
Thanks.
I couldn't execute heroku pgbackups
though, so I had to make the backup and download it via https://postgres.heroku.com/databases
Then, another problem arouse - my app wouldn't access the database (relation does not exist
error or no schema has been selected to create in
) and I had to run
grant usage on schema public to public;
grant create on schema public to public;
using psql
, inside the database.
Update: the command is now heroku pg:backups:capture
And heroku pg:backups
thanks!
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
Thanks.