backup 3.0.23 → 3.0.24
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +42 -45
- data/Guardfile +7 -4
- data/README.md +10 -7
- data/backup.gemspec +2 -2
- data/lib/backup.rb +27 -97
- data/lib/backup/archive.rb +14 -6
- data/lib/backup/cli/helpers.rb +52 -49
- data/lib/backup/cli/utility.rb +9 -1
- data/lib/backup/compressor/base.rb +10 -4
- data/lib/backup/compressor/bzip2.rb +22 -26
- data/lib/backup/compressor/custom.rb +53 -0
- data/lib/backup/compressor/gzip.rb +22 -23
- data/lib/backup/compressor/lzma.rb +15 -13
- data/lib/backup/compressor/pbzip2.rb +20 -17
- data/lib/backup/config.rb +6 -3
- data/lib/backup/configuration.rb +33 -0
- data/lib/backup/configuration/helpers.rb +114 -28
- data/lib/backup/configuration/store.rb +24 -0
- data/lib/backup/database/base.rb +0 -6
- data/lib/backup/database/mongodb.rb +27 -11
- data/lib/backup/database/mysql.rb +19 -14
- data/lib/backup/database/postgresql.rb +16 -11
- data/lib/backup/database/redis.rb +7 -11
- data/lib/backup/database/riak.rb +3 -6
- data/lib/backup/dependency.rb +5 -11
- data/lib/backup/model.rb +14 -5
- data/lib/backup/notifier/campfire.rb +3 -16
- data/lib/backup/notifier/hipchat.rb +1 -7
- data/lib/backup/notifier/mail.rb +1 -1
- data/lib/backup/packager.rb +29 -19
- data/lib/backup/pipeline.rb +110 -0
- data/lib/backup/storage/dropbox.rb +4 -7
- data/lib/backup/syncer/base.rb +8 -4
- data/lib/backup/syncer/cloud/base.rb +247 -0
- data/lib/backup/syncer/cloud/cloud_files.rb +78 -0
- data/lib/backup/syncer/cloud/s3.rb +68 -0
- data/lib/backup/syncer/rsync/base.rb +1 -4
- data/lib/backup/syncer/rsync/local.rb +9 -5
- data/lib/backup/syncer/rsync/pull.rb +1 -1
- data/lib/backup/syncer/rsync/push.rb +10 -5
- data/lib/backup/version.rb +1 -1
- data/spec-live/.gitignore +6 -0
- data/spec-live/README +7 -0
- data/spec-live/backups/config.rb +153 -0
- data/spec-live/backups/config.yml.template +43 -0
- data/spec-live/compressor/custom_spec.rb +30 -0
- data/spec-live/compressor/gzip_spec.rb +30 -0
- data/spec-live/notifier/mail_spec.rb +85 -0
- data/spec-live/spec_helper.rb +85 -0
- data/spec-live/storage/dropbox_spec.rb +151 -0
- data/spec-live/storage/local_spec.rb +83 -0
- data/spec-live/storage/scp_spec.rb +193 -0
- data/spec-live/syncer/cloud/s3_spec.rb +124 -0
- data/spec/archive_spec.rb +86 -31
- data/spec/cleaner_spec.rb +8 -0
- data/spec/cli/helpers_spec.rb +200 -75
- data/spec/cli/utility_spec.rb +11 -3
- data/spec/compressor/base_spec.rb +31 -10
- data/spec/compressor/bzip2_spec.rb +212 -57
- data/spec/compressor/custom_spec.rb +106 -0
- data/spec/compressor/gzip_spec.rb +212 -57
- data/spec/compressor/lzma_spec.rb +75 -35
- data/spec/compressor/pbzip2_spec.rb +93 -52
- data/spec/configuration/helpers_spec.rb +406 -0
- data/spec/configuration/store_spec.rb +39 -0
- data/spec/configuration_spec.rb +62 -0
- data/spec/database/base_spec.rb +19 -10
- data/spec/database/mongodb_spec.rb +195 -70
- data/spec/database/mysql_spec.rb +183 -64
- data/spec/database/postgresql_spec.rb +167 -53
- data/spec/database/redis_spec.rb +121 -46
- data/spec/database/riak_spec.rb +96 -27
- data/spec/dependency_spec.rb +2 -0
- data/spec/encryptor/base_spec.rb +10 -0
- data/spec/encryptor/gpg_spec.rb +29 -13
- data/spec/encryptor/open_ssl_spec.rb +40 -21
- data/spec/logger_spec.rb +4 -0
- data/spec/model_spec.rb +19 -2
- data/spec/notifier/base_spec.rb +32 -17
- data/spec/notifier/campfire_spec.rb +63 -45
- data/spec/notifier/hipchat_spec.rb +79 -56
- data/spec/notifier/mail_spec.rb +82 -46
- data/spec/notifier/prowl_spec.rb +53 -32
- data/spec/notifier/twitter_spec.rb +62 -41
- data/spec/packager_spec.rb +95 -36
- data/spec/pipeline_spec.rb +259 -0
- data/spec/spec_helper.rb +6 -5
- data/spec/storage/base_spec.rb +61 -41
- data/spec/storage/cloudfiles_spec.rb +69 -45
- data/spec/storage/dropbox_spec.rb +158 -36
- data/spec/storage/ftp_spec.rb +69 -45
- data/spec/storage/local_spec.rb +47 -23
- data/spec/storage/ninefold_spec.rb +55 -31
- data/spec/storage/rsync_spec.rb +67 -50
- data/spec/storage/s3_spec.rb +65 -41
- data/spec/storage/scp_spec.rb +65 -41
- data/spec/storage/sftp_spec.rb +65 -41
- data/spec/syncer/base_spec.rb +91 -4
- data/spec/syncer/cloud/base_spec.rb +511 -0
- data/spec/syncer/cloud/cloud_files_spec.rb +181 -0
- data/spec/syncer/cloud/s3_spec.rb +174 -0
- data/spec/syncer/rsync/base_spec.rb +46 -66
- data/spec/syncer/rsync/local_spec.rb +55 -26
- data/spec/syncer/rsync/pull_spec.rb +15 -4
- data/spec/syncer/rsync/push_spec.rb +59 -52
- data/templates/cli/utility/compressor/bzip2 +1 -4
- data/templates/cli/utility/compressor/custom +11 -0
- data/templates/cli/utility/compressor/gzip +1 -4
- data/templates/cli/utility/compressor/lzma +3 -0
- data/templates/cli/utility/compressor/pbzip2 +3 -0
- data/templates/cli/utility/database/mysql +4 -1
- data/templates/cli/utility/syncer/cloud_files +17 -19
- data/templates/cli/utility/syncer/s3 +18 -20
- metadata +38 -92
- data/lib/backup/configuration/base.rb +0 -15
- data/lib/backup/configuration/compressor/base.rb +0 -9
- data/lib/backup/configuration/compressor/bzip2.rb +0 -23
- data/lib/backup/configuration/compressor/gzip.rb +0 -23
- data/lib/backup/configuration/compressor/lzma.rb +0 -23
- data/lib/backup/configuration/compressor/pbzip2.rb +0 -28
- data/lib/backup/configuration/database/base.rb +0 -19
- data/lib/backup/configuration/database/mongodb.rb +0 -49
- data/lib/backup/configuration/database/mysql.rb +0 -42
- data/lib/backup/configuration/database/postgresql.rb +0 -41
- data/lib/backup/configuration/database/redis.rb +0 -39
- data/lib/backup/configuration/database/riak.rb +0 -29
- data/lib/backup/configuration/encryptor/base.rb +0 -9
- data/lib/backup/configuration/encryptor/gpg.rb +0 -17
- data/lib/backup/configuration/encryptor/open_ssl.rb +0 -32
- data/lib/backup/configuration/notifier/base.rb +0 -28
- data/lib/backup/configuration/notifier/campfire.rb +0 -25
- data/lib/backup/configuration/notifier/hipchat.rb +0 -41
- data/lib/backup/configuration/notifier/mail.rb +0 -112
- data/lib/backup/configuration/notifier/presently.rb +0 -25
- data/lib/backup/configuration/notifier/prowl.rb +0 -23
- data/lib/backup/configuration/notifier/twitter.rb +0 -21
- data/lib/backup/configuration/storage/base.rb +0 -18
- data/lib/backup/configuration/storage/cloudfiles.rb +0 -25
- data/lib/backup/configuration/storage/dropbox.rb +0 -58
- data/lib/backup/configuration/storage/ftp.rb +0 -29
- data/lib/backup/configuration/storage/local.rb +0 -17
- data/lib/backup/configuration/storage/ninefold.rb +0 -20
- data/lib/backup/configuration/storage/rsync.rb +0 -29
- data/lib/backup/configuration/storage/s3.rb +0 -25
- data/lib/backup/configuration/storage/scp.rb +0 -25
- data/lib/backup/configuration/storage/sftp.rb +0 -25
- data/lib/backup/configuration/syncer/base.rb +0 -10
- data/lib/backup/configuration/syncer/cloud.rb +0 -23
- data/lib/backup/configuration/syncer/cloud_files.rb +0 -30
- data/lib/backup/configuration/syncer/rsync/base.rb +0 -28
- data/lib/backup/configuration/syncer/rsync/local.rb +0 -11
- data/lib/backup/configuration/syncer/rsync/pull.rb +0 -11
- data/lib/backup/configuration/syncer/rsync/push.rb +0 -31
- data/lib/backup/configuration/syncer/s3.rb +0 -23
- data/lib/backup/notifier/presently.rb +0 -88
- data/lib/backup/syncer/cloud.rb +0 -187
- data/lib/backup/syncer/cloud_files.rb +0 -56
- data/lib/backup/syncer/s3.rb +0 -47
- data/spec/configuration/base_spec.rb +0 -35
- data/spec/configuration/compressor/bzip2_spec.rb +0 -29
- data/spec/configuration/compressor/gzip_spec.rb +0 -29
- data/spec/configuration/compressor/lzma_spec.rb +0 -29
- data/spec/configuration/compressor/pbzip2_spec.rb +0 -32
- data/spec/configuration/database/base_spec.rb +0 -17
- data/spec/configuration/database/mongodb_spec.rb +0 -56
- data/spec/configuration/database/mysql_spec.rb +0 -53
- data/spec/configuration/database/postgresql_spec.rb +0 -53
- data/spec/configuration/database/redis_spec.rb +0 -50
- data/spec/configuration/database/riak_spec.rb +0 -35
- data/spec/configuration/encryptor/gpg_spec.rb +0 -26
- data/spec/configuration/encryptor/open_ssl_spec.rb +0 -35
- data/spec/configuration/notifier/base_spec.rb +0 -32
- data/spec/configuration/notifier/campfire_spec.rb +0 -32
- data/spec/configuration/notifier/hipchat_spec.rb +0 -44
- data/spec/configuration/notifier/mail_spec.rb +0 -71
- data/spec/configuration/notifier/presently_spec.rb +0 -35
- data/spec/configuration/notifier/prowl_spec.rb +0 -29
- data/spec/configuration/notifier/twitter_spec.rb +0 -35
- data/spec/configuration/storage/cloudfiles_spec.rb +0 -41
- data/spec/configuration/storage/dropbox_spec.rb +0 -38
- data/spec/configuration/storage/ftp_spec.rb +0 -44
- data/spec/configuration/storage/local_spec.rb +0 -29
- data/spec/configuration/storage/ninefold_spec.rb +0 -32
- data/spec/configuration/storage/rsync_spec.rb +0 -41
- data/spec/configuration/storage/s3_spec.rb +0 -38
- data/spec/configuration/storage/scp_spec.rb +0 -41
- data/spec/configuration/storage/sftp_spec.rb +0 -41
- data/spec/configuration/syncer/cloud_files_spec.rb +0 -44
- data/spec/configuration/syncer/rsync/base_spec.rb +0 -33
- data/spec/configuration/syncer/rsync/local_spec.rb +0 -10
- data/spec/configuration/syncer/rsync/pull_spec.rb +0 -10
- data/spec/configuration/syncer/rsync/push_spec.rb +0 -43
- data/spec/configuration/syncer/s3_spec.rb +0 -38
- data/spec/notifier/presently_spec.rb +0 -181
- data/spec/syncer/cloud_files_spec.rb +0 -192
- data/spec/syncer/s3_spec.rb +0 -192
- data/templates/cli/utility/notifier/presently +0 -13
@@ -1,192 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
3
|
-
|
4
|
-
class Parallel; end
|
5
|
-
|
6
|
-
describe Backup::Syncer::CloudFiles do
|
7
|
-
describe '#perform!' do
|
8
|
-
let(:syncer) { Backup::Syncer::CloudFiles.new }
|
9
|
-
let(:connection) { stub('connection',
|
10
|
-
:directories => stub('directories', :get => container)) }
|
11
|
-
let(:container) { stub('container', :files => files) }
|
12
|
-
let(:files) { [] }
|
13
|
-
let(:content) { stub('content') }
|
14
|
-
|
15
|
-
before :each do
|
16
|
-
Fog::Storage.stubs(:new).returns connection
|
17
|
-
File.stubs(:open).returns content
|
18
|
-
File.stubs(:exist?).returns true
|
19
|
-
files.stubs(:create).returns true
|
20
|
-
|
21
|
-
syncer.directories << 'tmp'
|
22
|
-
syncer.path = 'storage'
|
23
|
-
Backup::Syncer::S3::SyncContext.any_instance.
|
24
|
-
stubs(:`).returns 'MD5(tmp/foo)= 123abcdef'
|
25
|
-
end
|
26
|
-
|
27
|
-
it "respects the concurrency_type setting with threads" do
|
28
|
-
syncer.concurrency_type = :threads
|
29
|
-
|
30
|
-
Parallel.expects(:each).with(anything, {:in_threads => 2}, anything)
|
31
|
-
|
32
|
-
syncer.perform!
|
33
|
-
end
|
34
|
-
|
35
|
-
it "respects the parallel thread count" do
|
36
|
-
syncer.concurrency_type = :threads
|
37
|
-
syncer.concurrency_level = 10
|
38
|
-
|
39
|
-
Parallel.expects(:each).with(anything, {:in_threads => 10}, anything)
|
40
|
-
|
41
|
-
syncer.perform!
|
42
|
-
end
|
43
|
-
|
44
|
-
it "respects the concurrency_type setting with processors" do
|
45
|
-
syncer.concurrency_type = :processes
|
46
|
-
|
47
|
-
Parallel.expects(:each).with(anything, {:in_processes => 2}, anything)
|
48
|
-
|
49
|
-
syncer.perform!
|
50
|
-
end
|
51
|
-
|
52
|
-
it "respects the parallel thread count" do
|
53
|
-
syncer.concurrency_type = :processes
|
54
|
-
syncer.concurrency_level = 10
|
55
|
-
|
56
|
-
Parallel.expects(:each).with(anything, {:in_processes => 10}, anything)
|
57
|
-
|
58
|
-
syncer.perform!
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'file exists locally' do
|
62
|
-
it "uploads a file if it does not exist remotely" do
|
63
|
-
files.expects(:create).with(:key => 'storage/tmp/foo', :body => content)
|
64
|
-
|
65
|
-
syncer.perform!
|
66
|
-
end
|
67
|
-
|
68
|
-
it "uploads a file if it exists remotely with a different MD5" do
|
69
|
-
files << stub('file', :key => 'storage/tmp/foo', :etag => 'abcdef123')
|
70
|
-
|
71
|
-
files.expects(:create).with(:key => 'storage/tmp/foo', :body => content)
|
72
|
-
|
73
|
-
syncer.perform!
|
74
|
-
end
|
75
|
-
|
76
|
-
it "does nothing if the file exists remotely with the same MD5" do
|
77
|
-
files << stub('file', :key => 'storage/tmp/foo', :etag => '123abcdef')
|
78
|
-
|
79
|
-
files.expects(:create).never
|
80
|
-
|
81
|
-
syncer.perform!
|
82
|
-
end
|
83
|
-
|
84
|
-
it "skips the file if it no longer exists locally" do
|
85
|
-
File.stubs(:exist?).returns false
|
86
|
-
|
87
|
-
files.expects(:create).never
|
88
|
-
|
89
|
-
syncer.perform!
|
90
|
-
end
|
91
|
-
|
92
|
-
it "respects the given path" do
|
93
|
-
syncer.path = 'box'
|
94
|
-
|
95
|
-
files.expects(:create).with(:key => 'box/tmp/foo', :body => content)
|
96
|
-
|
97
|
-
syncer.perform!
|
98
|
-
end
|
99
|
-
|
100
|
-
it "uploads the content of the local file" do
|
101
|
-
File.expects(:open).with('tmp/foo').returns content
|
102
|
-
|
103
|
-
syncer.perform!
|
104
|
-
end
|
105
|
-
|
106
|
-
it "creates the connection with the provided credentials" do
|
107
|
-
syncer.api_key = 'my-key'
|
108
|
-
syncer.username = 'my-name'
|
109
|
-
syncer.auth_url = 'my-auth'
|
110
|
-
syncer.servicenet = 'my-servicenet'
|
111
|
-
|
112
|
-
Fog::Storage.expects(:new).with(
|
113
|
-
:provider => 'Rackspace',
|
114
|
-
:rackspace_api_key => 'my-key',
|
115
|
-
:rackspace_username => 'my-name',
|
116
|
-
:rackspace_auth_url => 'my-auth',
|
117
|
-
:rackspace_servicenet => 'my-servicenet'
|
118
|
-
).returns connection
|
119
|
-
|
120
|
-
syncer.perform!
|
121
|
-
end
|
122
|
-
|
123
|
-
it "uses the container with the given name" do
|
124
|
-
syncer.container = 'leaky'
|
125
|
-
|
126
|
-
connection.directories.expects(:get).with('leaky').returns(container)
|
127
|
-
|
128
|
-
syncer.perform!
|
129
|
-
end
|
130
|
-
|
131
|
-
it "creates the container if one does not exist" do
|
132
|
-
syncer.container = 'leaky'
|
133
|
-
connection.directories.stubs(:get).returns nil
|
134
|
-
|
135
|
-
connection.directories.expects(:create).
|
136
|
-
with(:key => 'leaky').returns(container)
|
137
|
-
|
138
|
-
syncer.perform!
|
139
|
-
end
|
140
|
-
|
141
|
-
it "iterates over each directory" do
|
142
|
-
syncer.directories << 'files'
|
143
|
-
|
144
|
-
Backup::Syncer::CloudFiles::SyncContext.any_instance.expects(:`).
|
145
|
-
with('find tmp -print0 | xargs -0 openssl md5 2> /dev/null').
|
146
|
-
returns 'MD5(tmp/foo)= 123abcdef'
|
147
|
-
Backup::Syncer::CloudFiles::SyncContext.any_instance.expects(:`).
|
148
|
-
with('find files -print0 | xargs -0 openssl md5 2> /dev/null').
|
149
|
-
returns 'MD5(tmp/foo)= 123abcdef'
|
150
|
-
|
151
|
-
syncer.perform!
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context 'file does not exist locally' do
|
156
|
-
let(:file) { stub('file', :key => 'storage/tmp/foo',
|
157
|
-
:etag => '123abcdef') }
|
158
|
-
|
159
|
-
before :each do
|
160
|
-
Backup::Syncer::CloudFiles::SyncContext.any_instance.
|
161
|
-
stubs(:`).returns ''
|
162
|
-
files << file
|
163
|
-
File.stubs(:exist?).returns false
|
164
|
-
end
|
165
|
-
|
166
|
-
it "removes the remote file when mirroring is turned on" do
|
167
|
-
syncer.mirror = true
|
168
|
-
|
169
|
-
file.expects(:destroy).once
|
170
|
-
|
171
|
-
syncer.perform!
|
172
|
-
end
|
173
|
-
|
174
|
-
it "leaves the remote file when mirroring is turned off" do
|
175
|
-
syncer.mirror = false
|
176
|
-
|
177
|
-
file.expects(:destroy).never
|
178
|
-
|
179
|
-
syncer.perform!
|
180
|
-
end
|
181
|
-
|
182
|
-
it "does not remove files not under one of the specified directories" do
|
183
|
-
file.stubs(:key).returns 'unsynced/tmp/foo'
|
184
|
-
syncer.mirror = true
|
185
|
-
|
186
|
-
file.expects(:destroy).never
|
187
|
-
|
188
|
-
syncer.perform!
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
data/spec/syncer/s3_spec.rb
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
3
|
-
|
4
|
-
class Parallel; end
|
5
|
-
|
6
|
-
describe Backup::Syncer::S3 do
|
7
|
-
describe '#perform!' do
|
8
|
-
let(:syncer) { Backup::Syncer::S3.new }
|
9
|
-
let(:connection) { stub('connection',
|
10
|
-
:directories => stub('directories', :get => bucket)) }
|
11
|
-
let(:bucket) { stub('bucket', :files => files) }
|
12
|
-
let(:files) { [] }
|
13
|
-
let(:content) { stub('content') }
|
14
|
-
|
15
|
-
before :each do
|
16
|
-
Fog::Storage.stubs(:new).returns connection
|
17
|
-
File.stubs(:open).returns content
|
18
|
-
File.stubs(:exist?).returns true
|
19
|
-
files.stubs(:create).returns true
|
20
|
-
|
21
|
-
syncer.directories << 'tmp'
|
22
|
-
syncer.path = 'storage'
|
23
|
-
|
24
|
-
Backup::Syncer::S3::SyncContext.any_instance.
|
25
|
-
stubs(:`).returns 'MD5(tmp/foo)= 123abcdef'
|
26
|
-
end
|
27
|
-
|
28
|
-
it "respects the concurrency_type setting with threads" do
|
29
|
-
syncer.concurrency_type = :threads
|
30
|
-
|
31
|
-
Parallel.expects(:each).with(anything, {:in_threads => 2}, anything)
|
32
|
-
|
33
|
-
syncer.perform!
|
34
|
-
end
|
35
|
-
|
36
|
-
it "respects the parallel thread count" do
|
37
|
-
syncer.concurrency_type = :threads
|
38
|
-
syncer.concurrency_level = 10
|
39
|
-
|
40
|
-
Parallel.expects(:each).with(anything, {:in_threads => 10}, anything)
|
41
|
-
|
42
|
-
syncer.perform!
|
43
|
-
end
|
44
|
-
|
45
|
-
it "respects the concurrency_type setting with processors" do
|
46
|
-
syncer.concurrency_type = :processes
|
47
|
-
|
48
|
-
Parallel.expects(:each).with(anything, {:in_processes => 2}, anything)
|
49
|
-
|
50
|
-
syncer.perform!
|
51
|
-
end
|
52
|
-
|
53
|
-
it "respects the parallel thread count" do
|
54
|
-
syncer.concurrency_type = :processes
|
55
|
-
syncer.concurrency_level = 10
|
56
|
-
|
57
|
-
Parallel.expects(:each).with(anything, {:in_processes => 10}, anything)
|
58
|
-
|
59
|
-
syncer.perform!
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'file exists locally' do
|
63
|
-
it "uploads a file if it does not exist remotely" do
|
64
|
-
files.expects(:create).with(:key => 'storage/tmp/foo', :body => content)
|
65
|
-
|
66
|
-
syncer.perform!
|
67
|
-
end
|
68
|
-
|
69
|
-
it "uploads a file if it exists remotely with a different MD5" do
|
70
|
-
files << stub('file', :key => 'storage/tmp/foo', :etag => 'abcdef123')
|
71
|
-
|
72
|
-
files.expects(:create).with(:key => 'storage/tmp/foo', :body => content)
|
73
|
-
|
74
|
-
syncer.perform!
|
75
|
-
end
|
76
|
-
|
77
|
-
it "does nothing if the file exists remotely with the same MD5" do
|
78
|
-
files << stub('file', :key => 'storage/tmp/foo', :etag => '123abcdef')
|
79
|
-
|
80
|
-
files.expects(:create).never
|
81
|
-
|
82
|
-
syncer.perform!
|
83
|
-
end
|
84
|
-
|
85
|
-
it "skips the file if it no longer exists locally" do
|
86
|
-
File.stubs(:exist?).returns false
|
87
|
-
|
88
|
-
files.expects(:create).never
|
89
|
-
|
90
|
-
syncer.perform!
|
91
|
-
end
|
92
|
-
|
93
|
-
it "respects the given path" do
|
94
|
-
syncer.path = 'box'
|
95
|
-
|
96
|
-
files.expects(:create).with(:key => 'box/tmp/foo', :body => content)
|
97
|
-
|
98
|
-
syncer.perform!
|
99
|
-
end
|
100
|
-
|
101
|
-
it "uploads the content of the local file" do
|
102
|
-
File.expects(:open).with('tmp/foo').returns content
|
103
|
-
|
104
|
-
syncer.perform!
|
105
|
-
end
|
106
|
-
|
107
|
-
it "creates the connection with the provided credentials" do
|
108
|
-
syncer.access_key_id = 'my-access'
|
109
|
-
syncer.secret_access_key = 'my-secret'
|
110
|
-
syncer.region = 'somewhere'
|
111
|
-
|
112
|
-
Fog::Storage.expects(:new).with(
|
113
|
-
:provider => 'AWS',
|
114
|
-
:aws_access_key_id => 'my-access',
|
115
|
-
:aws_secret_access_key => 'my-secret',
|
116
|
-
:region => 'somewhere'
|
117
|
-
).returns connection
|
118
|
-
|
119
|
-
syncer.perform!
|
120
|
-
end
|
121
|
-
|
122
|
-
it "uses the bucket with the given name" do
|
123
|
-
syncer.bucket = 'leaky'
|
124
|
-
|
125
|
-
connection.directories.expects(:get).with('leaky').returns(bucket)
|
126
|
-
|
127
|
-
syncer.perform!
|
128
|
-
end
|
129
|
-
|
130
|
-
it "creates the bucket if one does not exist" do
|
131
|
-
syncer.bucket = 'leaky'
|
132
|
-
syncer.region = 'elsewhere'
|
133
|
-
connection.directories.stubs(:get).returns nil
|
134
|
-
|
135
|
-
connection.directories.expects(:create).
|
136
|
-
with(:key => 'leaky', :location => 'elsewhere').returns(bucket)
|
137
|
-
|
138
|
-
syncer.perform!
|
139
|
-
end
|
140
|
-
|
141
|
-
it "iterates over each directory" do
|
142
|
-
syncer.directories << 'files'
|
143
|
-
|
144
|
-
Backup::Syncer::S3::SyncContext.any_instance.expects(:`).
|
145
|
-
with('find tmp -print0 | xargs -0 openssl md5 2> /dev/null').
|
146
|
-
returns 'MD5(tmp/foo)= 123abcdef'
|
147
|
-
Backup::Syncer::S3::SyncContext.any_instance.expects(:`).
|
148
|
-
with('find files -print0 | xargs -0 openssl md5 2> /dev/null').
|
149
|
-
returns 'MD5(tmp/foo)= 123abcdef'
|
150
|
-
|
151
|
-
syncer.perform!
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context 'file does not exist locally' do
|
156
|
-
let(:file) { stub('file', :key => 'storage/tmp/foo',
|
157
|
-
:etag => '123abcdef') }
|
158
|
-
|
159
|
-
before :each do
|
160
|
-
Backup::Syncer::S3::SyncContext.any_instance.
|
161
|
-
stubs(:`).returns ''
|
162
|
-
files << file
|
163
|
-
File.stubs(:exist?).returns false
|
164
|
-
end
|
165
|
-
|
166
|
-
it "removes the remote file when mirroring is turned on" do
|
167
|
-
syncer.mirror = true
|
168
|
-
|
169
|
-
file.expects(:destroy).once
|
170
|
-
|
171
|
-
syncer.perform!
|
172
|
-
end
|
173
|
-
|
174
|
-
it "leaves the remote file when mirroring is turned off" do
|
175
|
-
syncer.mirror = false
|
176
|
-
|
177
|
-
file.expects(:destroy).never
|
178
|
-
|
179
|
-
syncer.perform!
|
180
|
-
end
|
181
|
-
|
182
|
-
it "does not remove files not under one of the specified directories" do
|
183
|
-
file.stubs(:key).returns 'unsynced/tmp/foo'
|
184
|
-
syncer.mirror = true
|
185
|
-
|
186
|
-
file.expects(:destroy).never
|
187
|
-
|
188
|
-
syncer.perform!
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Presently [Notifier]
|
3
|
-
#
|
4
|
-
notify_by Presently do |presently|
|
5
|
-
presently.on_success = true
|
6
|
-
presently.on_warning = true
|
7
|
-
presently.on_failure = true
|
8
|
-
|
9
|
-
presently.subdomain = "my_subdomain"
|
10
|
-
presently.user_name = "my_user_name"
|
11
|
-
presently.password = "my_password"
|
12
|
-
presently.group_id = "my_group_id" # optional
|
13
|
-
end
|