Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
store your rails database backups in the cloud
Ruby
tag: 0.4.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
HISTORY
README.rdoc
Rakefile
VERSION
db2fog.gemspec

README.rdoc

DB2Fog

A rails plugin to backup Mysql to a cloud storage provider. You're looking at a monthly spend of four cents. So pony up you cheap bastard, and store your backups offsite.

A grandfather style system to decide what backups to keep copies of:

  • all backups from the past 24 hours

  • one backup per day for the past week

  • one backup per week forever

Depending on your tolerance for data loss you should be running a backup at least once a day, probably more.

Installation

Add the following to your project Gemfile

gem "db2fog"

Configuration

Add the following to config/initializers/db2fog.rb

In general, you can use any configuration options supported by Fog::Storage.new, plus the :directory option. If fog adds support for extra providers they should work with just a config change to Db2Fog.

Amazon S3

DB2Fog.config = {
  :aws_access_key_id     => 'yourkey',
  :aws_secret_access_key => 'yoursecretkey',
  :directory             => 'bucket-name',
  :provider              => 'AWS'
}

Rackspace Cloudfiles

DB2Fog.config = {
  :rackspace_username => 'username',
  :rackspace_api_key  => 'api key',
  :directory          => 'bucket-name',
  :provider           => 'Rackspace'
}

Local Storage

DB2Fog.config = {
  :directory  => 'bucket-name',
  :local_root => Rails.root.to_s + '/db/backups',
  :provider   => 'Local'
}

Usage

# Add to your crontab or whatever
rake db2fog:backup:full

# Handy tasks
rake db2fog:statistics      # Shows you the size of your DB
rake db2fog:backup:restore  # You should be testing this regularly
rake db2fog:backup:clean    # Clean up old backups - cron this

Compatibility

This is pure so ruby should run on most ruby VMs. I develop on MRI 1.9.2.

This will only work work with rails 3. Supporting earlier versions is more complication than I can handle at the moment.

Development

Specs are really weak. This code is bit hackish but is being used by quite a few people.

Kudos

This is a fork of Xavier Shay's db2s3 gem. It worked perfectly, but only supported Amazon S3. By switching the dependency to using fog this now supports multiple storage providers.

Xavier's original gem is available at github.com/xaviershay/db2s3

Xavier quotes the following example as inspiration:

github.com/pauldowman/blog_code_examples/tree/master/mysql_s3_backup

Something went wrong with that request. Please try again.