Created
September 24, 2019 12:25
-
-
Save digerata/723f1a68a54c2514c229593ecf5dcf9d to your computer and use it in GitHub Desktop.
Pull down a database from Heroku. Assumes Rails db names.
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" | |
REMOTE="$2" | |
if [[ "$3" != "" ]]; then | |
ENVIRONMENT="$3" | |
else | |
ENVIRONMENT="development" | |
fi | |
DATABASE=$APPNAME | |
DATABASE+="_" | |
DATABASE+=$ENVIRONMENT | |
echo "App: $APPNAME" | |
echo "Remote: $REMOTE" | |
echo "Rails Env: $ENVIRONMENT" | |
echo "Database: $DATABASE" | |
function run_restore { | |
`pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d "$DATABASE" latest.dump` | |
} | |
`heroku pg:backups:capture --remote $REMOTE` | |
`heroku pg:backups:download --remote $REMOTE` | |
run_restore | |
`rm latest.dump` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment