Created
August 19, 2014 19:10
-
-
Save jonallured/c9c25c7951e03918beed to your computer and use it in GitHub Desktop.
sync heroku dbs
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
#!/usr/bin/env bash | |
remote="${1:-staging}" | |
capture() { | |
heroku pgbackups:capture --expire --remote $1 | |
} | |
url() { | |
heroku pgbackups:url --remote $1 | |
} | |
if [ $remote = clone ]; then | |
capture production | |
heroku pgbackups:restore DATABASE `url production` --remote staging --confirm connectsense-staging | |
else | |
capture $remote | |
curl -o snapshot.sql `url $remote` | |
pg_restore --verbose --clean --no-acl --no-owner -d connect_sense_development snapshot.sql | |
rm -f snapshot.sql | |
fi | |
echo "now reset passwords:" | |
echo "User.all.each { |u| u.password = u.password_confirmation = 'password'; u.save }" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment