Skip to content

Instantly share code, notes, and snippets.

@jnicho02
Created March 3, 2017 13:19
Show Gist options
  • Save jnicho02/d995dd86be427f0023aa961c99724f2a to your computer and use it in GitHub Desktop.
Save jnicho02/d995dd86be427f0023aa961c99724f2a to your computer and use it in GitHub Desktop.
a really useful script for Heroku + Rails. Generate a db backup, download it, create a new db, import data, update database config to point at it
heroku pg:backups capture --app open-plaques-beta
curl -o db/db.dump `heroku pg:backups --app open-plaques-beta public-url`
createdb openplaques_$(date +'%Y-%m-%d')
pg_restore -d openplaques_$(date +'%Y-%m-%d') db/db.dump
sed -iE "s/openplaques_[0-9|-]*/openplaques_$(date +'%Y-%m-%d')/g" config/database.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment