Skip to content

Instantly share code, notes, and snippets.

@tobyhede
Created August 6, 2012 22:42
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 tobyhede/3279145 to your computer and use it in GitHub Desktop.
Save tobyhede/3279145 to your computer and use it in GitHub Desktop.
Heoku Database Management

Note: These assume that pgbackups is activated for the app on heroku.

Snapshot & Local Restore

Snapshot the db and restore to your LOCAL database (about a zillion times faster than db:pull)

curl -o latest.dump  `heroku pgbackups:url --app {APP_NAME}`
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U {USER} -d {DB} latest.dump

Snapshot & Staging Restore

Snapshot production and push to staging (about a gazillion times faster than db:pull/db:push)

heroku pgbackups:restore DATABASE `heroku pgbackups:url --app {APP_NAME}` --app {APP_STAGING_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment