Last Updated: February 25, 2016
·
404
· evolve2k

How to Backup your Heroku database to your computer

Heroku provides lots of documentation as to how to do backups.
Unfortunately its still confusing as to how to just do a simple backup and get it on your computer.

This is because it is a 2 step process.

  1. Run this
$ heroku pgbackups:capture --expire

the expire deletes the oldest backup to make space

HEROKU_POSTGRESQL_YELLOW_URL (DATABASE_URL)  ----backup--->  b249
Capturing... done
Storing... done

The 'b249' is the ID of the backup, this is backup number 249. Your number will be different.

  1. Run this
$ heroku pgbackups:url b249

This will give you a tempory location you can download the backup from.

  1. Open the link in the web browser and it'll download your datbase backup dump file!

  2. Bonus Points: Use it with wget and download straight to your command line!