Created
August 6, 2014 17:11
-
-
Save justinhillsjohnson/3b1fea23df5c4598fd5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APPNAME=$1 | |
DBNAME=$2 | |
WAITING="==============================================================" | |
echo "Cloning database from heroku app $APPNAME." | |
echo "Note: You must have heroku toolbelt and postgres installed." | |
echo $WAITING | |
echo "Capturing new backup with --expire option" | |
heroku pgbackups:capture --expire --app $APPNAME | |
echo $WAITING | |
DBFILE="$HOME/desktop/latest.dump" | |
echo "Downloading db to your desktop as latest.dump" | |
curl -o $DBFILE `heroku pgbackups:url --app $APPNAME` | |
echo $WAITING | |
echo "Importing db to Rails dev database" | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U $USER -d $DBNAME $DBFILE | |
echo "Removing desktop db file." | |
rm $DBFILE | |
echo "Script Complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment