Skip to content

Instantly share code, notes, and snippets.

@davebrace
Created January 31, 2013 16:02
Show Gist options
  • Save davebrace/4683926 to your computer and use it in GitHub Desktop.
Save davebrace/4683926 to your computer and use it in GitHub Desktop.
Script to restore a Heroku postgres database from one Heroku Rails app to another, assuming only one postgres database in the app. I use this to copy production databases onto staging environments.
heroku pgbackups:capture --expire -a myapp
heroku pg:reset `heroku config -a myapp-staging | grep -o "\w*POSTGRESQL\w*"` -a myapp-staging
heroku pgbackups:restore `heroku config -a myapp-staging | grep -o "\w*POSTGRESQL\w*"` `heroku pgbackups:url --app myapp` --app myapp-staging
heroku run rake db:migrate -a myapp-staging
heroku restart -a myapp-staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment