Skip to content

Instantly share code, notes, and snippets.

@jonallured
Created August 19, 2014 19:10
Show Gist options
  • Save jonallured/c9c25c7951e03918beed to your computer and use it in GitHub Desktop.
Save jonallured/c9c25c7951e03918beed to your computer and use it in GitHub Desktop.
sync heroku dbs
#!/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