-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME
68 lines (52 loc) · 3.51 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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].