Skip to content

Instantly share code, notes, and snippets.

@franciscoafonsoo
Last active January 16, 2020 17:39
Show Gist options
  • Save franciscoafonsoo/8f5882f57bb374aebf8dae2c055375ac to your computer and use it in GitHub Desktop.
Save franciscoafonsoo/8f5882f57bb374aebf8dae2c055375ac to your computer and use it in GitHub Desktop.
PosgreSQL: Restore from an Heroku app to a local posgresql DB
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