Skip to content

Instantly share code, notes, and snippets.

@peralmq
Last active November 16, 2015 11:17
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 peralmq/42e1bd0add506ae121e4 to your computer and use it in GitHub Desktop.
Save peralmq/42e1bd0add506ae121e4 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Create a local database and populate with data from Heroku pg:backups
if [ $# != 2 ]; then
echo 1>&2 "usage: $0 BACKUP_ID APP_NAME"
exit 2
fi
BACKUP_ID=$1
APP_NAME=$2
BACKUP_FILE=/tmp/$BACKUP_ID.dump
createdb $BACKUP_ID
BACKUP_URL=`heroku pg:backups public-url $BACKUP_ID --app $APP_NAME`
wget -O $BACKUP_FILE $BACKUP_URL
pg_restore -d $BACKUP_ID $BACKUP_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment