Recent Projects

Poor Man’s Heroku Backups

Here’s a quick and dirty way to back up all of your Heroku-powered databases using their Taps gem with one easy command. It works well enough for my simple needs, but any improvements you’ve got would be most welcome!

Just add the following to your ~/.bash_profile, and you’re good to go:

Update: I’ve posted a technique for enabling automatic nightly PostgreSQL database backups from Heroku to Amazon S3 that may be of interest as well.

8 Responses to “Poor Man’s Heroku Backups”

  1. Mooktakim says:

    You get 1 backup free.

    $ heroku bundles:capture
    $ heroku bundles:download

    Keep it someplace

  2. Trevor says:

    Yeah, that could be easier, but I couldn’t figure out how to automate the destroying of that single bundle to make room for the new one. If this isn’t a problem anymore, or you have a solution, please let me know!

  3. Sam Rodgers says:

    bundle=backup
    app=myapp
    heroku bundles:capture $bundle –app $app
    sleep 15 # the capture takes a few seconds…
    heroku bundles:download $bundle –app $app
    heroku bundles:destroy $bundle –app $app

  4. Trevor says:

    That was easy. Thanks, Sam!

  5. Leo Wong says:

    Thanks for the helpful advices. It seems capturing a bundle is a more preferred way for backups. But I have a question: how to restore the raw dump file ‘pgdump.sql’, which is included in the downloaded bundle, to the database on Heroku?

  6. Matt Buck says:

    I recently created a heroku plugin for the purpose of automating the uploading of bundles to S3: http://herocutter.heroku.com/plugins/17

  7. Trevor says:

    @Matt – cool!

    I also came across this one, which looks pretty good, too:

    http://github.com/perezd/heroku_tools

  8. Matt Buck says:

    Thanks! Yeah, I found that one recently, as well. I think I like his method better, actually. I adapted my plugin from a rake task, so it’s still shelling out to the heroku gem. I’m just using the bundle capture functionality rather than pg_dump direct from the dyno.

Leave a Reply