Skip to content

Instantly share code, notes, and snippets.

@ewalk153
Created July 23, 2013 19:14
Show Gist options
  • Save ewalk153/6065269 to your computer and use it in GitHub Desktop.
Save ewalk153/6065269 to your computer and use it in GitHub Desktop.
heroku and postgres script to restore from the latest backup
#!/bin/sh
DIR="$(basename $(PWD))"
DIR="${DIR/-/_}"
if [ "$1" == "execute" ]
then
if [ ! -f 'dump.db' ]
then
echo "downloading backup"
curl `heroku pgbackups:url` > dump.db
fi
pg_restore --verbose --clean --no-acl --no-owner -d $DIR dump.db
echo "restore complete. Run rake tasks to update any necessary db changes"
else
echo "add execute to run"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment