Poor Man’s Heroku Backups

Posted by Trevor in Code, Ruby/Rails on September 11, 2009

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:

5 Comments

 Mooktakim

You get 1 backup free.

$ heroku bundles:capture
$ heroku bundles:download

Keep it someplace

 Trevor

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!

 Sam Rodgers

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

 Trevor

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?

Leave a comment

WP_Big_City