Created
July 15, 2013 16:36
-
-
Save the-swerve/6001409 to your computer and use it in GitHub Desktop.
Backup heroku db and transfer between production, staging, and localhost
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 add-on | |
heroku addons:add pgbackups -a staging_app_name | |
heroku addons:add pgbackups -a production_app_name | |
# Capture backups. Use --expire if your existing list is full. | |
heroku pgbackups:capture -a production_app_name | |
# Import production to localhost | |
curl -o latest.dump `heroku pgbackups:url -a production_app_name` | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U local_psql_username -d development_db_name latest.dump | |
# Transfer production db to staging db | |
heroku pgbackups:restore DATABASE `heroku pgbackups:url -a production_app_name` -a production_app_name -a staging_app_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
after all that, make sure you are in the correct (staging) folder locally
heroku run rake db:migrate