Last active
January 16, 2020 17:39
-
-
Save franciscoafonsoo/8f5882f57bb374aebf8dae2c055375ac to your computer and use it in GitHub Desktop.
PosgreSQL: Restore from an Heroku app to a local posgresql DB
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
function restore_db_heroku() { | |
: ${1?"Usage: $1 Heroku app; $2 Local DB"} | |
echo "Capturing a new backup and downloading..." | |
echo "" | |
heroku pg:backups:capture -a $1 | |
heroku pg:backups:download -a $1 | |
mv latest.dump "${1}_latest.dump" | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U sherby -d $2 "${1}_latest.dump" | |
echo "" | |
echo "${2} has the latest data from heroku's ${1}." | |
echo "Dump filename: "${1}_latest.dump"" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment