Backing up your database from Heroku

I’m writing a quick post on this, because every time I do it I fck around for a while and eventually get it – so this time I am writing my steps!

And yes, I know there is documentation on Heroku, but it never quite works for me. So!

  1. Make sure you have a database created and migrated into which you are going to put your backup
  2. Capture a backup with $heroku pg:backups capture --app rails-girls-events
  3. It will give you a backup id, which you can use in the next command to get the public url of that backup $heroku pg:backups public-url b006 --app rails-girls-events
  4. When you visit that url, it will download to your machine
  5. Use the path to that download to upload it $pg_restore --verbose --clean --no-acl --no-owner -h localhost -U tracymusung -d your-data-base-name path-to-your-download


Leave a reply