Last active
August 24, 2018 08:50
-
-
Save stevenharman/6241318 to your computer and use it in GitHub Desktop.
Capture a Heroku PostgreSQL backup, download it, and restore it to your local development database.
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/sh | |
set -e | |
app=$1 | |
local_db=${app}_development | |
# Create the backup on heroku | |
heroku pgbackups:capture --expire | |
# Download the backup | |
curl -# -o /tmp/${app}.dump `heroku pgbackups:url` | |
# Restore the backup | |
pg_restore --verbose --clean --no-acl --no-owner -h 127.0.0.1 -U `whoami` -d ${local_db} /tmp/${app}.dump | |
# Clean up | |
rm -f /tmp/${app}.dump | |
set +e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing :)