9 Ruby on Rails Backup Solutions

by Stuart

If you run a business or application built with Rails then one of the key first things to address is ensuring things are always backed up, daily where possible. I’m sure you’ve all heard the horror stories, there are lots of them.

There’s a few things to consider here:

  1. The cost needed to develop a solution to manage the backups
  2. Where to store the backups
  3. The cost of storage associated with the backups
  4. The impact running a backup might have on the current server resources
  5. How to restore backups in the event of a crash/hack

Luckily for you, there’s a number of solutions out there that not only make backups a breeze, but also do in a very, very cost efficient manner.

Amazon S3Almost all of the solutions below utilize Amazon’s S3 storage, which costs around $0.15 per GB / month to store data.

Things get more expensive when you need to backup Photos, Videos or other large media files. But for your site, database & any repositories it should be extremely cheap.One thing to note also is that Amazon keeps up to 3 copies of your backups in at least 2 different geographical locations, which is a major win.

Libraries / Gems / Plugins

Adam’s S3 Rake Task

Adam’s Rake Task makes it incredibly easy to get backups up & running in a matter of minutes. Once installed you can backup quicky with the rake command:

rake s3:backup

Backup Fu

Backup Fu is another rake task that (in their own words) makes backups redonkulously easy. This gem also allows the restore of PostgreSQL databases.

There’s also a very very handy restore command:

BACKUP_FILE=myapp_1999-12-31_12345679_db.tar.gz rake backup_fu:restore

Backup Gem

Backup is a very powerful & configurable gem. You can specify some of the following options:

  1. What is being archived (files, folders, arbitrary scripts)
  2. How it’s being archived (tar gzip, bz2)
  3. Where the archive is going (multiple backup servers? easy)
  4. How the archive is going to get there (scp, ftp, mv)
  5. Where is will be stored when it gets there
  6. How it’s going to be rotated when it gets there (grandfather-father-son, etc)
  7. How often will this process happen (customizable cycles)
  8. What happens to the working copy after the process (recreate files, folders etc. restart daemons)

Backup

Backup is another Ruby Gem that offers encryption & cycling with backups. You can also choose to receive email notifications when backups are completed. You don’t have to use Amazon S3 with Backup, you can choose to backup anywhere that you can SCP or SFTP into.

DB2S3

DB2S3 is written by a fellow melburnian Xavier Shay, it allows you to quite simply back up your DB & archive on Amazon S3. It also has a handy restore feature:

rake db2s3:backup:restore

AWSS-3

AWSS-3 is a Ruby Library for Amazon’s S3 REST API. This gives you much more control over what you want to store & how you want to store it (buckets). You will need to create your own rake task using the library to back up your data, but you’ll have increased flexibility.

WordPress S3 Backups via Rails

Chances are if you run an application you might have a blog (just like this one) to communicate with your customers or audience. The changing nature of blogging platforms (WordPress is no exception here) leaves blog highly vulnerable to hacking. We covered briefly before how to automate your wordpress updgrades via the commandline.

The WordPress S3 Backup plugin allows you to backup your blog with a rake task (which you can set via a nightly cronjob).

Applications

Backup My App

Backup My App

Backup My App is exclusively for Ruby on Rails applications & provides a visual interface for Backups. You can view changes, browse previous backups & restore.

There’s a free plan that allows you to store up to 1GB. They do however charge $0.60 per Gigabyte ($0.45 more than S3 using the gems/plugins above).

Dropbox

Whilst Dropbox doesn’t provide SSH access you can still SSH to a box that has Dropbox installed then use SCP to copy your backups (which are then synced to anyone that is shared to that folder).

Enjoy Shopping? StoreCrowd launches beta on Oct 4th. Join us for an advanced preview & become the Boss of your favourite store

  • I've got one that I rolled myself, I've been meaning to package it up as a gem and make it public. Will try and do that in the next couple of days.

    Watch http://rubypond.com/blog/devops for a post on it
  • barmstrong
    Any recommendations on which is the BEST?
  • vitaly
    astrails-safe :)
  • vitaly
    Hey, you forgot astrails-safe: http://astrails.com/astrails-safe
    its the most popular by the github metrics: http://ruby-toolbox.com/categories/backups.html

    it supports
    dumps:
    * mysql
    * postgres
    * filesystem
    * subversion

    storage:
    * local
    * sftp
    * s3
    * rackspace cloudfiles

    backups can be encrypted with gpg

    backups can be rotated

    or, and all this goodness is configured with a very simple ruby dsl!
  • We'll get Astrails added Vitlay, makes it a nice round number 10 :)

    Love some of the projects you guys are working on Thounds & MarkupSlicer are very slick.

    Cheers
    Stuart
  • Thanks for the comment Chris, we're primarily Rails developers here so hence the reason that the article is targeted to that Language.

    We're in no way educated enough to know decent backup solutions for Python (for example).

    Cheers
    Stuart
  • Chris
    Why is this targeted at Rails? Surely this is important regardless of language and framework that an app is written with?

Previous post:

Next post: