Skip to content

Instantly share code, notes, and snippets.

@joeybaker
Created September 15, 2012 00:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeybaker/3725709 to your computer and use it in GitHub Desktop.
Save joeybaker/3725709 to your computer and use it in GitHub Desktop.
Import a DB from Heroku. Only, be fast about.
#! /bin/bash
#
# You should do a find/replace for APPNAME, LOCALDBUSER, and LOCALDBNAME
#
# via https://devcenter.heroku.com/articles/pgbackups#importing-from-a-backup, https://github.com/heroku/heroku/issues/556
# by: @joeybaker
heroku pgbackups:capture --expire --app APPNAME
curl -o latest.sql `heroku pgbackups:url --app APPNAME`
pg_restore --verbose --clean --no-acl --no-owner -U LOCALDBUSER -d LOCALDBNAME latest.sql
rm latest.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment