Forked from jackkinsella/Better Database Pulling With Heroku
Last active
December 12, 2015 02:49
-
-
Save jmeridth/4702421 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 | |
# Best use case is to create a file "update_local_db.sh" in your project folder and then call the command with bash update_local_db | |
function LastBackupName () { | |
heroku pgbackups | tail -n 1 | awk '{print $1;}' | |
} | |
# This part assumes you have a low limit on no. of backups allowed | |
old_backup=$(LastBackupName) | |
heroku pgbackups:destroy $old_backup | |
heroku pgbackups:capture | |
new_backup=$(LastBackupName) | |
curl $(heroku pgbackups:url $new_backup) > temporary_backup.dump | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U playworks -d playworks_development temporary_backup.dump | |
rm -f temporary_backup.dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment