Skip to content

Instantly share code, notes, and snippets.

@grobertson
Created July 8, 2013 17:55
Show Gist options
  • Save grobertson/5950950 to your computer and use it in GitHub Desktop.
Save grobertson/5950950 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ -z "$1" ]]; then
FAIL=1
elif [[ -z "$2" ]]; then
FAIL=1
fi
if [[ -n "$FAIL" ]];then
echo "Usage: $0 SOURCE DESTINATION"
echo "Where SOURCE and DESTINATION are Heroku app names."
exit 1
fi
SOURCE=$1
DESTINATION=$2
#Never allow this script to restore to the dailydot app for safety.
if [ "$DESTINATION" = "dailydot" ]; then
echo "Cowardly refusing to restore to the production app. You're on your own, buddy."
exit 1
else
echo "Restoring backup of $SOURCE to $DESTINATION"
heroku pgbackups:restore DATABASE_URL -a $DESTINATION `heroku pgbackups:url -a $SOURCE` --confirm $DESTINATION
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment