colin-safe 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -2
- data/VERSION.yml +1 -1
- data/bin/astrails-safe +1 -1
- data/lib/astrails/safe/s3.rb +14 -18
- metadata +6 -5
data/Rakefile
CHANGED
@@ -9,10 +9,10 @@ begin
|
|
9
9
|
gem.description = "Simple tool to backup MySQL databases and filesystem locally or to Amazon S3 (with optional encryption)"
|
10
10
|
gem.email = "we@astrails.com"
|
11
11
|
gem.homepage = "http://github.com/astrails/safe"
|
12
|
-
gem.authors = ["Astrails Ltd."]
|
12
|
+
gem.authors = ["Astrails Ltd.", "Colin Schlueter"]
|
13
13
|
gem.files = FileList["[A-Z]*.*", "{bin,examples,generators,lib,rails,spec,test,templates}/**/*", 'Rakefile', 'LICENSE*']
|
14
14
|
|
15
|
-
gem.add_dependency("
|
15
|
+
gem.add_dependency("right_aws")
|
16
16
|
|
17
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
18
|
end
|
data/VERSION.yml
CHANGED
data/bin/astrails-safe
CHANGED
data/lib/astrails/safe/s3.rb
CHANGED
@@ -12,42 +12,34 @@ module Astrails
|
|
12
12
|
@prefix ||= expand(config[:s3, :path] || expand(config[:local, :path] || ":kind/:id"))
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
15
|
+
def base
|
16
|
+
@base ||= File.basename(filename).split(".").first
|
17
|
+
end
|
18
18
|
|
19
|
+
def save
|
19
20
|
file = @parent.open
|
20
21
|
puts "Uploading #{bucket}:#{path}" if $_VERBOSE || $DRY_RUN
|
21
22
|
unless $DRY_RUN || $LOCAL
|
22
|
-
|
23
|
-
|
23
|
+
s3.create_bucket(bucket)
|
24
|
+
s3.put(bucket, path, file)
|
24
25
|
puts "...done" if $_VERBOSE
|
25
26
|
end
|
26
27
|
file.close if file
|
27
|
-
|
28
28
|
end
|
29
29
|
|
30
30
|
def cleanup
|
31
|
-
|
32
31
|
return if $LOCAL
|
33
|
-
|
34
32
|
return unless keep = @config[:keep, :s3]
|
35
33
|
|
36
|
-
bucket = @config[:s3, :bucket]
|
37
|
-
|
38
|
-
base = File.basename(filename).split(".").first
|
39
|
-
|
40
34
|
puts "listing files in #{bucket}:#{prefix}/#{base}"
|
41
|
-
files =
|
42
|
-
puts files.collect {|x| x
|
35
|
+
files = s3.list_bucket(bucket, { 'prefix' => "#{prefix}/#{base}", 'max-keys' => keep * 2 })
|
36
|
+
puts files.collect {|x| x[:key]} if $_VERBOSE
|
43
37
|
|
44
|
-
files = files.
|
45
|
-
collect {|x| x.key}.
|
46
|
-
sort
|
38
|
+
files = files.collect {|x| x[:key]}.sort
|
47
39
|
|
48
40
|
cleanup_with_limit(files, keep) do |f|
|
49
41
|
puts "removing s3 file #{bucket}:#{f}" if $DRY_RUN || $_VERBOSE
|
50
|
-
|
42
|
+
s3.delete(bucket, f) unless $DRY_RUN || $LOCAL
|
51
43
|
end
|
52
44
|
end
|
53
45
|
|
@@ -63,6 +55,10 @@ module Astrails
|
|
63
55
|
config[:s3, :secret]
|
64
56
|
end
|
65
57
|
|
58
|
+
def s3
|
59
|
+
@s3 ||= RightAws::S3Interface.new(key, secret)
|
60
|
+
end
|
61
|
+
|
66
62
|
end
|
67
63
|
end
|
68
64
|
end
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colin-safe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Astrails Ltd.
|
8
|
+
- Colin Schlueter
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-04-
|
13
|
+
date: 2009-04-24 00:00:00 -07:00
|
13
14
|
default_executable: astrails-safe
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
+
name: right_aws
|
17
18
|
type: :runtime
|
18
19
|
version_requirement:
|
19
20
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -80,9 +81,9 @@ requirements: []
|
|
80
81
|
rubyforge_project:
|
81
82
|
rubygems_version: 1.2.0
|
82
83
|
signing_key:
|
83
|
-
specification_version:
|
84
|
+
specification_version: 3
|
84
85
|
summary: Backup filesystem and MySQL to Amazon S3 (with encryption)
|
85
86
|
test_files:
|
86
87
|
- examples/example_helper.rb
|
87
|
-
- examples/unit/stream_example.rb
|
88
88
|
- examples/unit/config_example.rb
|
89
|
+
- examples/unit/stream_example.rb
|