Last active
December 21, 2015 05:38
-
-
Save bshyong/6257817 to your computer and use it in GitHub Desktop.
Bash script to pull Heroku DB to local environment - note that this creates a manual backup via heroku pgbackups:capture
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 | |
# call command with bash pull_production_to_local | |
function LastBackupName () { | |
heroku pgbackups --app APPNAME | tail -n 1 | cut -d " " -f 1 | |
} | |
heroku pgbackups:capture --expire --app APPNAME | |
new_backup=$(LastBackupName) | |
curl $(heroku pgbackups:url $new_backup --app APPNAME) -k > db/temporary_backup.dump | |
dropdb development -h localhost | |
createdb development -h localhost | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d development db/temporary_backup.dump | |
rm -f db/temporary_backup.dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment