Forked from jackkinsella/Better Database Pulling With Heroku
Last active
December 23, 2015 18:19
-
-
Save explodi/6675367 to your computer and use it in GitHub Desktop.
Now heroku separates columns in pgbackups output with space instead of pipe
This file contains hidden or 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 | |
| # Follow me: @jackkinsella | |
| function LastBackupName () { | |
| heroku pgbackups | tail -n 1 | cut -d" " -f 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 REPLACE_WITH_YOUR_USER -d REPLACE_WITH_YOUR_DB_NAME 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