Generally helpful rake tasks to backup code/scm/database to and from S3
Ruby
Latest commit f277879 May 5, 2008 Adam Greene adding the original s3 rake task
Permalink
Failed to load latest commit information.
lib first commit May 5, 2008
tasks adding the original s3 rake task May 5, 2008
templates first commit May 5, 2008
README first commit May 5, 2008
Rakefile first commit May 5, 2008
install.rb first commit May 5, 2008

README

S3RakeTasks
===========

= S3 Rake - Use S3 as a backup repository for your SVN repository, code directory, and MySQL database

Author::    Adam Greene
Copyright:: (c) 2006 6 Bar 8, LLC., Sweetspot.dm
License::   GNU

Feedback appreciated: adam at [nospam] 6bar8 dt com

== Synopsis

 from the CommandLine within your RubyOnRails application folder
 $ rake -T
   rake s3:backup                      # Backup code, database, and scm to S3
   rake s3:backup:code                 # Backup the code to S3
   rake s3:backup:db                   # Backup the database to S3
   rake s3:backup:scm                  # Backup the scm repository to S3
   rake s3:manage:clean_up             # Remove all but the last 10 most recent backup archive or optionally specify KEEP=5 to keep
                                           the last 5
   rake s3:manage:delete_bucket        # delete bucket.  You need to pass in NAME=bucket_to_delete.  Set FORCE=true if you want to 
                                       #   delete the bucket even if there are items in it.
   rake s3:manage:list                 # list all your backup archives
   rake s3:manage:list_buckets         # list all your S3 buckets
   rake s3:retrieve                    # retrieve the latest revision of code, database, and scm from S3. 
                                       #   If  you need to specify a specific version, call the individual retrieve tasks
   rake s3:retrieve:code               # retrieve the latest code backup from S3, or optionally specify a VERSION=this_archive.tar.gz
   rake s3:retrieve:db                 # retrieve the latest db backup from S3, or optionally specify a VERSION=this_archive.tar.gz
   rake s3:retrieve:scm                # retrieve the latest scm backup from S3, or optionally specify a VERSION=this_archive.tar.gz

== Description

 There are a few prerequisites to get this up and running:
   * please download the Amazon S3 ruby library and place it in your ./lib/ directory
     http://developer.amazonwebservices.com/connect/entry.jspa?externalID=135&categoryID=47
   * You will need a 's3.yml' file in ./config/.  Sure, you can hard-code the information in this rake task,
     but I like the idea of keeping all your configuration information in one place.  The File will need to look like:
       aws_access_key: '<YOUR ACCESS KEY HERE>'
       aws_secret_access_key: '<YOUR _SECRET_ ACCESS KEY HERE>'
       options:
           use_ssl: true #set it to true or false

 Once these two requirements are met, you can easily integrate these rake tasks into capistrano tasks or into cron.
   * For cron, put this into a file like <your.app.name>.backup.cron.  You can drop this file into /etc/cron.daily,
     and make sure you chmod +x <your.app.name>.backup.cron.  Also make sure it is owned by the appropriate user (probably 'root'.):

     #!/bin/sh

     # change the paths as you need...
     cd /var/www/apps/<your.app>/current/ && rake s3:backup >/dev/null 2>&1
     cd /var/www/apps/staging.<your.app>/current/ && rake s3:backup >/dev/null 2>&1

   * within your capistrano recipe file, you can tasks like these:

    task :before_update_code, :roles => [:app, :db, :web] do
       # this will back up your svn repository, your code directory, and your mysql db.
       run "cd #{current_path} && rake --trace RAILS_ENV=production s3:backup"
    end

== Credits and License

 inspired by rshll, developed by Dominic Da Silva:
   http://rubyforge.org/projects/rsh3ll/

This library is licensed under the GNU General Public License (GPL)
 [http://dev.perl.org/licenses/gpl1.html].