Backup is a Ruby Gem written for Unix and Rails environments. It can be used both with and without the Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as MySQL/PostgreSQL and Files/Folders. All backups can be transferred to Amazon S3 or any remote server you have access to, using either SCP, SFTP…
Switch branches/tags
Nothing to show
Pull request Compare This branch is 135 commits ahead, 1262 commits behind backup:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
generators/backup
lib
setup
.document
.gitignore
CHANGELOG
LICENSE
README.textile
Rakefile
VERSION
backup.gemspec

README.textile

Backup

A Backup Ruby Gem

Backup is a Ruby Gem written for Unix and Rails environments. It can be used both with and without the Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as MySQL/PostgreSQL and Files/Folders. All backups can be transferred to Amazon S3 or any remote server you have access to, using either SCP, SFTP or regular FTP. Backup handles Compression, Archiving, Encryption and Backup Cleaning (Cycling).

New Commands as of 2.3.0.2

Finders

Unix Environment:

sudo backup --find [trigger]

Rails Environment:

rake backup:find trigger='trigger'

Finders in Table Format

Unix Environment:

sudo backup --table --find [trigger]

Rails Environment:

rake backup:find trigger='trigger' table=true

Backup goes independent with the release of version 2.3.0! Ruby on Rails is no longer “required”!

Before you read on, let me tell you that even though all this awesomeness has been added, Backup will still work as it did in the previous version with Ruby on Rails!

I am pleased to announce that Backup (version 2.3.0+) has been released and am very satisfied with this update. Backup can now make use of an executable bin file! Why is this so awesome? Because now Backup is Ruby on Rails independent! This means you can make use of Backup whether you use Rails or not, and with the same simplicity! (pshh.. It’s actually simpler to be honest!).

Imagine you have one or more web applications written in another language on the same server, for example, a Python or PHP application. It’d be nice if you could also back up these databases in the same way you are used to, using Backup. Or what about having a MySQL Server running on a separate remote server? It’d be nice to be able to backup directly from that server instead of create a dump from there to the application’s server and then push it to Amazon S3 or elsewhere. Previously this wasn’t really possible. But now it is! Check this out.

Install Backup Gem version 2.3.0 or later!

sudo gem install backup

Setup Backup

sudo backup --setup

New folders and files are created in /opt/backup, these will look familiar if you’ve been using Backup.. Edit the config file!
The configuration file works 100% the same as the Ruby on Rails configuration file, so no need to re-understand it!

sudo nano /opt/backup/config/backup.rb

And now just run it like so!

sudo backup --run mytrigger

For a full list of commands:

backup --help

Another handy command I added to this backup utility, is the ability to decrypt files that were encrypted by Backup.

sudo backup --decrypt /path/to/encrypted/file

Get started with Backup in the Unix environment!

http://wiki.github.com/meskyanichi/backup/getting-started-unix

(Current) Backup’s Capabilities

Storage Methods

  • Amazon (S3)
  • Remote Server (SCP)
  • Remote Server (SFTP)
  • Remote Server (FTP)

Adapters

  • MySQL
  • PostgreSQL
  • Archive (any files or folders)
  • Custom (any database format other than MySQL or PostgreSQL!)

Archiving

Backup supports Archiving.
When you use the Archive adapter to backup a bunch of files and folders, backup will archive and compress these all together.
Archiving also happens when using the Custom adapter. If you issue a few commands using it, to dump maybe 1-3 databases, Backup will
handle the archiving, compression and encryption for you!

Encryption

Backup supports a simple form of encryption.
All adapters support encryption. This is very simple to enable. Just add the following method inside of the backup settings
of which you wish to encrypt, and it will encrypt it with the specified password:

encrypt_with_password "mypassword"

As of Backup 2.3.0, backup is executable through the command line. To decrypt an encrypted file, backup provides you with a handy utility to do this:

sudo backup --decrypt /path/to/encrypted/file

Backup Cleaning

Backup supports backup cleaning.
Backup Cleaning enables you to specify the amount of backups that may be stored on either Amazon S3 or a Remote Server. If you for example tell backup to limit the amount of backups at 20, then when the 21st backup gets pushed to the storage location, the oldest version will automatically be destroyed.

The idea behind this is to not flood either your backup server, which might resort in possible lack of hard disk space. Another good reason to utilize this would be for Amazon. Although Amazon S3 is extremely cheap, when backing up 1-2GB of MySQL dumps twice a day, it can become quite expensive if you never remove old ones.

To enable this you simply call the following method inside the desired “backup setting”:

keep_backups 20

Quick Example of a Single Backup Setting inside the Backup Configuration File

backup 'mysql-backup-s3' do
  adapter :mysql do
    user      'user'
    password  'password'
    database  'database'
  end
  storage :s3 do
    access_key_id     'access_key_id'
    secret_access_key 'secret_access_key'
    bucket            '/bucket/backups/mysql/'
    use_ssl           true
  end
  keep_backups 25
  encrypt_with_password 'password'
end

The (backup ‘mysql-backup-s3’ do) is what I call a “backup setting”. The first argument of the block is the so called “trigger”.

backup 'mysql-backup-s3' do
  # Configuration Here
end

This acts as an “identifier” for the “backup setting”. The (above) “backup setting” is all pretty straightforward.
So now that we’ve set up a “backup setting”, we can run it using a rake task, like so:

rake backup:run trigger="mysql-backup-s3"

That’s it, the MySQL database has been “backed up” to Amazon S3. It has been dumped, compressed and encrypted with password.
Note: You can add as many “backup setting” blocks as you want inside the “config/backup.rb” configuration file and invoke each of them by their own “trigger”. This means you can have as many backup setups as you want, which “don’t” all run simultaneously when you initialize a backup.

Depending on what environment you’re running backup on, you will use different commands. Rails uses Rake Tasks, while Unix uses regular executable commands. See below!

Runs the backup setting with the trigger “backup-logs”

rake backup:run trigger="backup-logs"
sudo backup --run backup-logs

Runs the backup setting with the trigger “backup-mysql”

rake backup:run trigger="backup-mysql"
sudo backup --run backup-mysql

Runs the backup setting with the trigger “backup-assets”

rake backup:run trigger="backup-assets"
sudo backup --run backup-assets

Additional Options for MySQL and PostgreSQL

You can pass additional options/flags into the MySQL and PostgreSQL adapters via additional_options. For example:

backup 'mysql-backup-s3' do
  adapter :mysql do
    user      'user'
    password  'password'
    database  'database'
    additional_options '--single-transaction'
  end
  .
  .
end

Interested in trying out Backup?

Check out the following Wiki pages to get up and running:

Getting started (Unix Environment)

http://wiki.github.com/meskyanichi/backup/getting-started-unix

Getting started (Rails Environment)

http://wiki.github.com/meskyanichi/backup/getting-started-ruby-on-rails

Production Mode (important)

http://wiki.github.com/meskyanichi/backup/production-mode

Backup Configuration File (All Adapters, Storage Methods and Options)

http://wiki.github.com/meskyanichi/backup/configuration-file

Rake Tasks

http://wiki.github.com/meskyanichi/backup/rake-tasks

Automatic Backups

http://wiki.github.com/meskyanichi/backup/automatic-backups

Capistrano Recipes

http://wiki.github.com/meskyanichi/backup/capistrano-recipes

Capistrano, Whenever!

http://wiki.github.com/meskyanichi/backup/capistrano-whenever

Understanding “The Backup Database”

http://wiki.github.com/meskyanichi/backup/the-backup-database

Trouble Shooting

http://wiki.github.com/meskyanichi/backup/troubleshooting

Requirements

http://wiki.github.com/meskyanichi/backup/requirements

Resources

http://wiki.github.com/meskyanichi/backup/resources

Requests

If anyone has any requests, please send me a message!

Suggestions?

Send me a message! Fork the project!

Found a Bug?

http://github.com/meskyanichi/backup/issues

Contributors

List of people that forked and added stuff!

Copyright

Copyright © 2009 Michael van Rooijen | Final Creation. (http://final-creation.com) See LICENSE for details.