Created
May 7, 2018 05:57
-
-
Save maclunar/14a333c43db07e48e19e196d44803ece to your computer and use it in GitHub Desktop.
Replace local database with latest heroku dump
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 | |
# from app $1 to local database $2 | |
# | |
# Place this in your /usr/local/bin folder and add execution privelages | |
# Example usage: | |
# replace_with_production_db my_app_name my_app_database_dev | |
echo “Downloading database from $1...” | |
curl -o latest_db.dump `heroku pg:backups public-url --app $1` | |
echo “Dropping database $2...” | |
dropdb $2 | |
echo “Creating new database - $2...” | |
createdb $2 -O `whoami` | |
echo “Restoring database form $1 to $2...” | |
pg_restore --verbose --clean --no-acl --no-owner -U `whoami` -d $2 latest_db.dump | |
rm latest_db.dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment