Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jmeridth/4702421 to your computer and use it in GitHub Desktop.
Save jmeridth/4702421 to your computer and use it in GitHub Desktop.
#!/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