Xavier’s original code depended on the aws-s3 gem. aws-s3 works well enough, however it appears to be unmaintained and has a few rough edges. In particular, it doesn’t cleanly handle S3 regions outside US-east. It also uses class variables for configuration, making it difficult to authenticate with alternate accounts at other points in my application.
The solution to these issues was to switch the dependency from aws-s3 to fog, a newer gem that is actively maintained. As a bonus, it also brings us support for additional storage providers like Rackspace cloudfiles and Ninefold.
To use it, start by adding it to the Gemfile in your rails app:
Then configure it by putting this in config/initializers/db2fog.rb:
Now use the rake tasks to perform backups and restores. Run them manually first, then add them to cron for automatic backups. I recommend running a few backup every few hours and the clean task daily.
That’s it! A dead simple way to get offsite backups that will probably cost you only cents per month. For details and examples for configuring sotrage providers like Rackspace check the project README on github.