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.
You get 1 backup free.
$ heroku bundles:capture
$ heroku bundles:download
Keep it someplace
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!
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
That was easy. Thanks, Sam!
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?
I recently created a heroku plugin for the purpose of automating the uploading of bundles to S3: http://herocutter.heroku.com/plugins/17
@Matt – cool!
I also came across this one, which looks pretty good, too:
http://github.com/perezd/heroku_tools
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.