Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I download db from heroku?

I'm using heroku and I want to download the database from my app(heroku) so I can make some changes in it, I've installed pgbackups, but using heroku pgbackups:url downloads a .dump file

How can I download a postgresql file or translate that .dump into a postgresql file?

like image 644
Sascuash Avatar asked Jun 10 '13 11:06

Sascuash


People also ask

Does Heroku save database?

Heroku Postgres delivers the world's most advanced open source database as a trusted, secure, and scalable service that is optimized for developers.


2 Answers

If you're using Heroku's pgbackups (which you probably should be using):

$ heroku pg:backups capture $ curl -o latest.dump `heroku pg:backups public-url` 

"Translate" it into a postgres db with

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

See https://devcenter.heroku.com/articles/heroku-postgres-import-export

like image 189
AlexQueue Avatar answered Oct 04 '22 08:10

AlexQueue


There's a command for this in the CLI - heroku db:pull which will do this for you. db:pull can be a bit slow mind you so you may be better to use the next option.

If you are using complex postgress data types (hstore, arrays etc) then you need to use the pgtransfer plugin https://github.com/ddollar/heroku-pg-transfer which will basically does a backup on Heroku and a restores it locally.

UPDATE: db:pull and db:push have been deprecated and should be replaced with pg:pull and pg:push - read more at https://devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull

like image 36
John Beynon Avatar answered Oct 04 '22 07:10

John Beynon