Sorry this page looks weird. It was automatically migrated from my old blog, which had a different layout and different CSS.

Backing Up Your Rails Apps' Databases

I’m sure you already back up your production databases so this post will be of academic interest only.

For the rest of us who have been living life on the edge, here’s a Ruby script that backs up all of your applications' production databases.

It’s designed to work on a ‘standard’ (i.e. fabulous) Rails Machine so, if that’s you, just drop it on the file system somewhere and run it from cron. It should Just Work.

If you’re not on Rails Machine, you should be able to adapt it to your server’s setup without much fuss. Unless you’re running a database cluster, in which case you probably have somebody to do this for you anyway.

Disclaimer: please at least read through the script before running it on your own production databases. And back them up manually before running it, just in case. If it all goes pear-shaped then you can be sure that I’ll be in hiding on an inaccessible tropical beach somewhere.

Update: here are scripts for rolling over log files, clearing out sessions and dumping your Subversion repositories.

Andrew Stewart • 13 February 2007 • RailsDeployment
You can reach me by email or on Twitter.