Skip to content

Instantly share code, notes, and snippets.

@nickgartmann
Last active August 29, 2015 13:59
Show Gist options
  • Save nickgartmann/10900459 to your computer and use it in GitHub Desktop.
Save nickgartmann/10900459 to your computer and use it in GitHub Desktop.
Bash script to capture and clone a heroku database into a local development database.
if test -z $1 || test -z $2
then
printf "Usage: clone-database heroku-app-name database-name\n"
exit
fi
echo "Capturing backup"
heroku pgbackups:capture -e -a $1
echo "Pulling dump"
curl -o /tmp/$1-latest.dump `heroku pgbackups:url -a $1`
echo "Loading into local"
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d $2 /tmp/$1-latest.dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment