Skip to content

Commit

Permalink
cleanup for cloud files, readme etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly committed Dec 21, 2009
1 parent d0e5811 commit 457cfe8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,5 +1,6 @@
* quote values in mysql password file
* add 'lib' to $:
* [EXPERIMENTAL] Rackspace Cloud Files support

0.2.6

Expand Down
15 changes: 10 additions & 5 deletions README.markdown
Expand Up @@ -29,6 +29,10 @@ The following functionality was contributed by astrails-safe users:
* Subversion dump using svndump (by Richard Luther <richard.luther@gmail.com>)
* SFTP remote storage (by Adam <adam@mediadrive.ca>)
* benchmarking output (By Neer)
* README fixes (by Bobby Wilson)
* improved config file parsing (by Fedor Kocherga <fkocherga@gmail.com>)
* mysql password file quoting (by Jonathan Sutherland <jonathan.sutherland@gmail.com>)
* Rackspace Cloud Files support (by H. Wade Minter <minter@lunenburg.org>)

Thanks to all :)

Expand All @@ -51,7 +55,7 @@ Usage
-h, --help This help screen
-v, --verbose be verbose, duh!
-n, --dry-run just pretend, don't do anything.
-L, --local skip S3 and Cloud Files
-L, --local skip remote storage, only do local backups

Note: CONFIG_FILE will be created from template if missing

Expand Down Expand Up @@ -132,15 +136,15 @@ Example configuration
bucket "backup.astrails.com"
path "servers/alpha/:kind/:id"
end

cloudfiles do
username "..........."
api_key "................................."
container "safe_backup"
path ":kind/" # this is default
service_net false
end

sftp do
host "sftp.astrails.com"
user "astrails"
Expand All @@ -158,8 +162,9 @@ Example configuration

keep do
local 20
s3 30
cloudfiles 30
s3 100
cloudfiles 100
sftp 100
end

mysqldump do
Expand Down
12 changes: 5 additions & 7 deletions lib/astrails/safe/cloudfiles.rb
Expand Up @@ -5,19 +5,18 @@ class Cloudfiles < Sink
protected

def active?
container && username && api_key
container && user && api_key
end

def path
@path ||= expand(config[:cloudfiles, :path] || config[:local, :path] || ":kind/:id")
end

def save

raise RuntimeError, "pipe-streaming not supported for S3." unless @backup.path

# needed in cleanup even on dry run
cf = CloudFiles::Connection.new(username, api_key, true, service_net) unless $LOCAL
cf = CloudFiles::Connection.new(user, api_key, true, service_net) unless $LOCAL
puts "Uploading #{container}:#{full_path} from #{@backup.path}" if $_VERBOSE || $DRY_RUN
unless $DRY_RUN || $LOCAL
benchmark = Benchmark.realtime do
Expand All @@ -35,9 +34,8 @@ def cleanup

return unless keep = @config[:keep, :cloudfiles]


puts "listing files: #{container}:#{base}*" if $_VERBOSE
cf = CloudFiles::Connection.new(username, api_key, true, service_net) unless $LOCAL
cf = CloudFiles::Connection.new(user, api_key, true, service_net) unless $LOCAL
files = cf.container(container).objects(:prefix => base)

cleanup_with_limit(files, keep) do |f|
Expand All @@ -50,8 +48,8 @@ def container
@config[:cloudfiles, :container]
end

def username
@config[:cloudfiles, :username]
def user
@config[:cloudfiles, :user]
end

def api_key
Expand Down
2 changes: 1 addition & 1 deletion lib/astrails/safe/config/builder.rb
Expand Up @@ -3,7 +3,7 @@ module Safe
module Config
class Builder
COLLECTIONS = %w/database archive repo/
ITEMS = %w/s3 cloudfiles key secret bucket username api_key container service_net path gpg password keep local mysqldump pgdump options
ITEMS = %w/s3 cloudfiles key secret bucket api_key container service_net path gpg password keep local mysqldump pgdump options
user host port socket skip_tables tar files exclude filename svndump repo_path sftp/
NAMES = COLLECTIONS + ITEMS
def initialize(node)
Expand Down
1 change: 0 additions & 1 deletion lib/astrails/safe/s3.rb
Expand Up @@ -41,7 +41,6 @@ def cleanup

return unless keep = @config[:keep, :s3]


puts "listing files: #{bucket}:#{base}*" if $_VERBOSE
files = AWS::S3::Bucket.objects(bucket, :prefix => base, :max_keys => keep * 2)
puts files.collect {|x| x.key} if $_VERBOSE
Expand Down
9 changes: 3 additions & 6 deletions templates/script.rb
Expand Up @@ -23,12 +23,12 @@

## alternative style:
# s3 :key => YOUR_S3_KEY, :secret => YOUR_S3_SECRET, :bucket => S3_BUCKET, :path => ":kind/"

## uncomment to enable uploads to Rackspace Cloud Files
## http://www.rackspacecloud.com/cloud_hosting_products/files
## Rackspace auth (optional)
# cloudfiles do
# username "YOUR_RACKSPACE_CLOUD_USERNAME"
# user "YOUR_RACKSPACE_CLOUD_USERNAME"
# api_key "YOUR_RACKSPACE_API_KEY"
# container "YOUR_CONTAINER_NAME"
# # path for uploads to Cloud Files, supports same substitution like :local/:path
Expand All @@ -37,10 +37,7 @@
# # to back up over the private (unbilled) service net, set this value to true.
# # service_net true
# end

## alternative style:
# cloudfiles :username => YOUR_RACKSPACE_USERNAME, :api_key => YOUR_RACKSPACE_API_KEY, :container => CONTAINER_NAME, :path => ":kind/"


## uncomment to enable uploads via SFTP
# sftp do
# host "YOUR_REMOTE_HOSTNAME"
Expand Down

0 comments on commit 457cfe8

Please sign in to comment.