Last active
November 28, 2016 04:09
-
-
Save ChunAllen/9e476c901acd82d08cc36feaeeba9e4d to your computer and use it in GitHub Desktop.
Backup Heroku Database and Restore to Local
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
$ heroku login --> Login to your Heroku account using CLI | |
Create latest dump from heroku app | |
$ heroku pg:backups capture --app [heroku-remote] | |
$ heroku pg:backups public-url [database_num] --app [app_name] | |
$ curl -o latest.dump ‘[database_url]' | |
Restoring to your local | |
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U [username] -d [database name] latest.dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Restoring data from
production
tostaging
Make sure you backup the latest data from production
$ heroku pg:backups public-url [database_num] --app [production_app]
Note:
$ heroku pg:backups restore [database_url] DATABASE_URL --app [staging_app]