Skip to content

Instantly share code, notes, and snippets.

@atomkirk
Last active December 17, 2015 09:39
Show Gist options
  • Save atomkirk/5588904 to your computer and use it in GitHub Desktop.
Save atomkirk/5588904 to your computer and use it in GitHub Desktop.
Download Heroku DB
  1. Use heroku pgbackups to get url of latest backup:

     heroku pgbackups:url
    
  2. Download the .dump file.

  3. Create a db to restore into:

     psql -c "create database firehose_live_backup"
    

(note: show current dbs with psql then \list)

  1. Restore into the new db:

     pg_restore --verbose --clean --no-acl --no-owner -h localhost -U adamkirk -d firehose_live_backup ~/Downloads/a483.dump
    

And a bash script to do it all for you:

    heroku pgbackups:capture --expire --app firehose-api
    url=`heroku pgbackups:url --app firehose-api`
    curl $url > ~/Downloads/live_fh_copy.dump
    psql -c "drop database firehose_live_backup"
    psql -c "create database firehose_live_backup"
    pg_restore --verbose --clean --no-acl --no-owner -h localhost -U adamkirk -d firehose_live_backup ~/Downloads/live_fh_copy.dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment