Skip to content

Instantly share code, notes, and snippets.

@dillonhafer
Last active August 29, 2015 14:10
Show Gist options
  • Save dillonhafer/1bbd3a89442eede397f4 to your computer and use it in GitHub Desktop.
Save dillonhafer/1bbd3a89442eede397f4 to your computer and use it in GitHub Desktop.
Push local database to heroku
function dumper {
if (( $# != 1 )); then
echo "Usage: dumper [DATABASE]"
echo "Creates pg_dump: pg_dump -Fc --no-acl --no-owner DATABASE > DATABASE.dump"
else
pg_dump -Fc --no-acl --no-owner $1 > $1.dump
fi
}
function push_dev_db {
if (( $# != 1 )); then
echo "Usage: push_dev_db [DATABASE]"
echo "Copies local db to heroku"
else
dumper $1 &&
scp $1.dump server:files &&
rm $1.dump &&
heroku pgbackups:restore DATABASE "http://server/files/$1.dump"
ssh server "rm files/$1.dump"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment