forked from skippy/s3_rake_tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
70 lines (52 loc) · 3.81 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
68
69
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
Modified by Ben Greenberg (ben at ben<dontspamme>greenberg dot net) December 2008:
* Utilize the S3 configuration file format used by attachment_fu to keep things nice and DRY.
* Remove relative paths from require statements so rake file can be placed anywhere in app path.
This file has been updated accordingly.
== 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:
* You need the aws-s3 gem installed: sudo gem install aws-s3.
* You will need a 'amazon_s3.yml' file in ./config/. The file is the same format used by attachment_fu, so if you are using that things will work without any additional configuration. Note that the bucket_name option is not used by these tasks; bucket name is generated automatically. See the file in the templates directory for an example with additional options.
* Copy the aws/s3 directory to your lib directory.
* Place the rake file tasks/s3_tasks.rake file in your lib/tasks directory.
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].