Add the following to your .bash_profile
/ .profile
/ whatever:
function heroku_pg_pull(){
echo "! WARNING: Data in the local database '$2' will be destroyed."
echo " Type '$2' to overwrite data in local database '$2'"
read -p "> " local_database_name
echo
if [ "$local_database_name" == "$2" ]; then
curl -o heroku_pg_pull_latest_backup.dump `heroku pgbackups:url -a $1`;
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U `whoami` -d $2 heroku_pg_pull_latest_backup.dump;
rm heroku_pg_pull_latest_backup.dump;
else
echo "Aborted"
fi
}
You only need to do this once.
After you have that available, run the following commands to pull from a remote heroku database:
$ heroku pgbackups:capture --expire -a my_heroku_app_name
$ heroku_pg_pull my_heroku_app_name my_local_db_name