Skip to content

Instantly share code, notes, and snippets.

@SalahHamza
Created September 13, 2019 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SalahHamza/b4b490ac0651ab792c7baf3bf8b426ae to your computer and use it in GitHub Desktop.
Save SalahHamza/b4b490ac0651ab792c7baf3bf8b426ae to your computer and use it in GitHub Desktop.
Import a Heroku PG dump into local machine

Import a Heroku PG dump into local machine

Follow these 4 simple steps in your terminal (Heroku Dev Center): Create a backup copy of your database:

$ heroku pg:backups capture DATABASE_NAME

Download the copy from Heroku (to your local machine) using curl:

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

Load it*:

$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U YOUR_USERNAME -d DATABASE_NAME latest.dump

get YOUR_USERNAME and choose the desired database from your config/database.yml file. DATABASE_NAME can be your development/test/production db (Ex. mydb_development) That's it!

Source

Import a Heroku PG dump into local machine

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