-
-
Save stefanneculai/7695620 to your computer and use it in GitHub Desktop.
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 | |
# This script does the following: | |
# 1/ capture and download the latest backup | |
# 2/ load it to your local database | |
# Just replace any uppercase string with your own data | |
# | |
# CAPTURE | |
# | |
cd YOUR_LOCAL_BACKUP_FOLDER | |
heroku pgbackups:capture --expire --app YOUR_APP_NAME | |
file_path="db_$(date +%Y_%m_%d-%H_%M_%S).dump" | |
curl `heroku pgbackups:url --app YOUR_APP_NAME` > $file_path | |
# | |
# LOAD | |
# | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U YOUR_LOCAL_DB_USERNAME -d YOUR_LOCAL_DB_NAME $file_path | |
cd YOUR_LOCAL_APP # for me something like ~/Sites/app_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment