backup 3.0.27 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +1 -1
- data/README.md +139 -386
- data/bin/backup +1 -7
- data/lib/backup.rb +3 -9
- data/lib/backup/archive.rb +26 -20
- data/lib/backup/cleaner.rb +2 -2
- data/lib/backup/cli.rb +366 -0
- data/lib/backup/compressor/base.rb +2 -2
- data/lib/backup/compressor/gzip.rb +35 -1
- data/lib/backup/config.rb +1 -2
- data/lib/backup/database/base.rb +2 -2
- data/lib/backup/database/mongodb.rb +3 -3
- data/lib/backup/database/mysql.rb +3 -2
- data/lib/backup/database/postgresql.rb +3 -2
- data/lib/backup/database/riak.rb +18 -5
- data/lib/backup/dependency.rb +144 -93
- data/lib/backup/encryptor/base.rb +2 -2
- data/lib/backup/logger.rb +108 -110
- data/lib/backup/logger/console.rb +51 -0
- data/lib/backup/logger/logfile.rb +113 -0
- data/lib/backup/logger/syslog.rb +116 -0
- data/lib/backup/model.rb +67 -65
- data/lib/backup/notifier/base.rb +1 -1
- data/lib/backup/notifier/hipchat.rb +1 -1
- data/lib/backup/notifier/mail.rb +1 -1
- data/lib/backup/notifier/pushover.rb +6 -3
- data/lib/backup/packager.rb +4 -4
- data/lib/backup/pipeline.rb +17 -3
- data/lib/backup/splitter.rb +2 -2
- data/lib/backup/storage/base.rb +2 -2
- data/lib/backup/storage/cloudfiles.rb +2 -2
- data/lib/backup/storage/dropbox.rb +4 -4
- data/lib/backup/storage/ftp.rb +2 -2
- data/lib/backup/storage/local.rb +2 -2
- data/lib/backup/storage/ninefold.rb +2 -2
- data/lib/backup/storage/rsync.rb +3 -3
- data/lib/backup/storage/s3.rb +2 -2
- data/lib/backup/storage/scp.rb +2 -6
- data/lib/backup/storage/sftp.rb +2 -5
- data/lib/backup/syncer/base.rb +1 -1
- data/lib/backup/syncer/cloud/base.rb +15 -8
- data/lib/backup/syncer/rsync/local.rb +1 -1
- data/lib/backup/syncer/rsync/pull.rb +1 -1
- data/lib/backup/syncer/rsync/push.rb +1 -1
- data/lib/backup/utilities.rb +211 -0
- data/lib/backup/version.rb +1 -1
- data/templates/cli/{utility/archive → archive} +4 -8
- data/templates/cli/{utility/compressor → compressor}/bzip2 +0 -0
- data/templates/cli/{utility/compressor → compressor}/custom +0 -0
- data/templates/cli/{utility/compressor → compressor}/gzip +0 -0
- data/templates/cli/{utility/compressor → compressor}/lzma +0 -0
- data/templates/cli/{utility/compressor → compressor}/pbzip2 +0 -0
- data/templates/cli/config +68 -0
- data/templates/cli/{utility/database → database}/mongodb +1 -1
- data/templates/cli/{utility/database → database}/mysql +1 -1
- data/templates/cli/{utility/database → database}/postgresql +1 -1
- data/templates/cli/{utility/database → database}/redis +0 -0
- data/templates/cli/database/riak +20 -0
- data/templates/cli/{utility/encryptor → encryptor}/gpg +0 -0
- data/templates/cli/{utility/encryptor → encryptor}/openssl +0 -0
- data/templates/cli/{utility/model.erb → model.erb} +4 -4
- data/templates/cli/{utility/notifier → notifier}/campfire +0 -0
- data/templates/cli/{utility/notifier → notifier}/hipchat +0 -0
- data/templates/cli/{utility/notifier → notifier}/mail +0 -0
- data/templates/cli/{utility/notifier → notifier}/prowl +0 -0
- data/templates/cli/{utility/notifier → notifier}/pushover +0 -0
- data/templates/cli/{utility/notifier → notifier}/twitter +0 -0
- data/templates/cli/{utility/splitter → splitter} +0 -0
- data/templates/cli/{utility/storage → storage}/cloud_files +0 -0
- data/templates/cli/{utility/storage → storage}/dropbox +0 -0
- data/templates/cli/{utility/storage → storage}/ftp +0 -0
- data/templates/cli/{utility/storage → storage}/local +0 -0
- data/templates/cli/{utility/storage → storage}/ninefold +0 -0
- data/templates/cli/{utility/storage → storage}/rsync +0 -0
- data/templates/cli/{utility/storage → storage}/s3 +0 -0
- data/templates/cli/{utility/storage → storage}/scp +0 -0
- data/templates/cli/{utility/storage → storage}/sftp +0 -0
- data/templates/cli/{utility/syncer → syncer}/cloud_files +0 -0
- data/templates/cli/{utility/syncer → syncer}/rsync_local +0 -0
- data/templates/cli/{utility/syncer → syncer}/rsync_pull +0 -0
- data/templates/cli/{utility/syncer → syncer}/rsync_push +0 -0
- data/templates/cli/{utility/syncer → syncer}/s3 +0 -0
- metadata +55 -131
- data/.gitignore +0 -8
- data/.travis.yml +0 -10
- data/Gemfile +0 -28
- data/Guardfile +0 -23
- data/backup.gemspec +0 -32
- data/lib/backup/cli/helpers.rb +0 -93
- data/lib/backup/cli/utility.rb +0 -255
- data/spec-live/.gitignore +0 -6
- data/spec-live/README +0 -7
- data/spec-live/backups/config.rb +0 -83
- data/spec-live/backups/config.yml.template +0 -46
- data/spec-live/backups/models.rb +0 -184
- data/spec-live/compressor/custom_spec.rb +0 -30
- data/spec-live/compressor/gzip_spec.rb +0 -30
- data/spec-live/encryptor/gpg_keys.rb +0 -239
- data/spec-live/encryptor/gpg_spec.rb +0 -287
- data/spec-live/notifier/mail_spec.rb +0 -121
- data/spec-live/spec_helper.rb +0 -151
- data/spec-live/storage/dropbox_spec.rb +0 -151
- data/spec-live/storage/local_spec.rb +0 -83
- data/spec-live/storage/scp_spec.rb +0 -193
- data/spec-live/syncer/cloud/s3_spec.rb +0 -124
- data/spec/archive_spec.rb +0 -335
- data/spec/cleaner_spec.rb +0 -312
- data/spec/cli/helpers_spec.rb +0 -301
- data/spec/cli/utility_spec.rb +0 -411
- data/spec/compressor/base_spec.rb +0 -52
- data/spec/compressor/bzip2_spec.rb +0 -217
- data/spec/compressor/custom_spec.rb +0 -106
- data/spec/compressor/gzip_spec.rb +0 -217
- data/spec/compressor/lzma_spec.rb +0 -123
- data/spec/compressor/pbzip2_spec.rb +0 -165
- data/spec/config_spec.rb +0 -321
- data/spec/configuration/helpers_spec.rb +0 -247
- data/spec/configuration/store_spec.rb +0 -39
- data/spec/configuration_spec.rb +0 -62
- data/spec/database/base_spec.rb +0 -63
- data/spec/database/mongodb_spec.rb +0 -510
- data/spec/database/mysql_spec.rb +0 -411
- data/spec/database/postgresql_spec.rb +0 -353
- data/spec/database/redis_spec.rb +0 -334
- data/spec/database/riak_spec.rb +0 -176
- data/spec/dependency_spec.rb +0 -51
- data/spec/encryptor/base_spec.rb +0 -40
- data/spec/encryptor/gpg_spec.rb +0 -909
- data/spec/encryptor/open_ssl_spec.rb +0 -148
- data/spec/errors_spec.rb +0 -306
- data/spec/logger_spec.rb +0 -367
- data/spec/model_spec.rb +0 -666
- data/spec/notifier/base_spec.rb +0 -104
- data/spec/notifier/campfire_spec.rb +0 -217
- data/spec/notifier/hipchat_spec.rb +0 -211
- data/spec/notifier/mail_spec.rb +0 -316
- data/spec/notifier/prowl_spec.rb +0 -138
- data/spec/notifier/pushover_spec.rb +0 -123
- data/spec/notifier/twitter_spec.rb +0 -153
- data/spec/package_spec.rb +0 -61
- data/spec/packager_spec.rb +0 -213
- data/spec/pipeline_spec.rb +0 -259
- data/spec/spec_helper.rb +0 -60
- data/spec/splitter_spec.rb +0 -120
- data/spec/storage/base_spec.rb +0 -166
- data/spec/storage/cloudfiles_spec.rb +0 -254
- data/spec/storage/cycler_spec.rb +0 -247
- data/spec/storage/dropbox_spec.rb +0 -480
- data/spec/storage/ftp_spec.rb +0 -271
- data/spec/storage/local_spec.rb +0 -259
- data/spec/storage/ninefold_spec.rb +0 -343
- data/spec/storage/rsync_spec.rb +0 -362
- data/spec/storage/s3_spec.rb +0 -245
- data/spec/storage/scp_spec.rb +0 -233
- data/spec/storage/sftp_spec.rb +0 -244
- data/spec/syncer/base_spec.rb +0 -109
- data/spec/syncer/cloud/base_spec.rb +0 -515
- data/spec/syncer/cloud/cloud_files_spec.rb +0 -181
- data/spec/syncer/cloud/s3_spec.rb +0 -174
- data/spec/syncer/rsync/base_spec.rb +0 -98
- data/spec/syncer/rsync/local_spec.rb +0 -149
- data/spec/syncer/rsync/pull_spec.rb +0 -98
- data/spec/syncer/rsync/push_spec.rb +0 -333
- data/spec/version_spec.rb +0 -21
- data/templates/cli/utility/config +0 -32
- data/templates/cli/utility/database/riak +0 -11
@@ -1,151 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe 'Storage::Dropbox',
|
6
|
-
:if => Backup::SpecLive::CONFIG['storage']['dropbox']['specs_enabled'] do
|
7
|
-
let(:trigger) { 'archive_dropbox' }
|
8
|
-
|
9
|
-
def remote_files_for(storage, package)
|
10
|
-
remote_path = storage.send(:remote_path_for, package)
|
11
|
-
|
12
|
-
files = []
|
13
|
-
storage.send(:transferred_files_for, package) do |local_file, remote_file|
|
14
|
-
files << File.join(remote_path, remote_file)
|
15
|
-
end
|
16
|
-
files
|
17
|
-
end
|
18
|
-
|
19
|
-
def check_remote_for(storage, package, expectation = true)
|
20
|
-
remote_path = storage.send(:remote_path_for, package)
|
21
|
-
|
22
|
-
# search the remote_path folder for the trigger (base file name)
|
23
|
-
metadata = storage.send(:connection).search(
|
24
|
-
remote_path, package.trigger
|
25
|
-
)
|
26
|
-
files_found = metadata.map {|entry| File.basename(entry['path']) }
|
27
|
-
|
28
|
-
files = remote_files_for(storage, package).map {|file| File.basename(file) }
|
29
|
-
|
30
|
-
if expectation
|
31
|
-
files_found.sort.should == files.sort
|
32
|
-
else
|
33
|
-
files_found.should be_empty
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def clean_remote!(storage, package)
|
38
|
-
storage.send(:remove!, package)
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should store the archive on the remote', :init => true do
|
42
|
-
model = h_set_trigger(trigger)
|
43
|
-
|
44
|
-
model.perform!
|
45
|
-
|
46
|
-
storage = model.storages.first
|
47
|
-
package = model.package
|
48
|
-
files = remote_files_for(storage, package)
|
49
|
-
files.count.should == 1
|
50
|
-
|
51
|
-
check_remote_for(storage, package)
|
52
|
-
|
53
|
-
clean_remote!(storage, package)
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'Storage::Dropbox Cycling' do
|
57
|
-
context 'when archives exceed `keep` setting' do
|
58
|
-
it 'should remove the oldest archive' do
|
59
|
-
packages = []
|
60
|
-
|
61
|
-
model = h_set_trigger(trigger)
|
62
|
-
storage = model.storages.first
|
63
|
-
model.perform!
|
64
|
-
package = model.package
|
65
|
-
package.filenames.count.should == 1
|
66
|
-
packages << package
|
67
|
-
sleep 1
|
68
|
-
|
69
|
-
check_remote_for(storage, packages[0])
|
70
|
-
|
71
|
-
model = h_set_trigger(trigger)
|
72
|
-
storage = model.storages.first
|
73
|
-
model.perform!
|
74
|
-
package = model.package
|
75
|
-
package.filenames.count.should == 1
|
76
|
-
packages << package
|
77
|
-
sleep 1
|
78
|
-
|
79
|
-
check_remote_for(storage, packages[1])
|
80
|
-
|
81
|
-
model = h_set_trigger(trigger)
|
82
|
-
storage = model.storages.first
|
83
|
-
model.perform!
|
84
|
-
package = model.package
|
85
|
-
package.filenames.count.should == 1
|
86
|
-
packages << package
|
87
|
-
|
88
|
-
check_remote_for(storage, packages[2])
|
89
|
-
clean_remote!(storage, packages[2])
|
90
|
-
|
91
|
-
check_remote_for(storage, packages[1])
|
92
|
-
clean_remote!(storage, packages[1])
|
93
|
-
|
94
|
-
check_remote_for(storage, packages[0], false)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'when an archive to be removed does not exist' do
|
99
|
-
it 'should log a warning and continue' do
|
100
|
-
packages = []
|
101
|
-
|
102
|
-
model = h_set_trigger(trigger)
|
103
|
-
storage = model.storages.first
|
104
|
-
model.perform!
|
105
|
-
package = model.package
|
106
|
-
package.filenames.count.should == 1
|
107
|
-
packages << package
|
108
|
-
sleep 1
|
109
|
-
|
110
|
-
check_remote_for(storage, packages[0])
|
111
|
-
|
112
|
-
model = h_set_trigger(trigger)
|
113
|
-
storage = model.storages.first
|
114
|
-
model.perform!
|
115
|
-
package = model.package
|
116
|
-
package.filenames.count.should == 1
|
117
|
-
packages << package
|
118
|
-
|
119
|
-
check_remote_for(storage, packages[1])
|
120
|
-
|
121
|
-
# remove archive directory cycle! will attempt to remove
|
122
|
-
clean_remote!(storage, packages[0])
|
123
|
-
|
124
|
-
check_remote_for(storage, packages[0], false)
|
125
|
-
|
126
|
-
check_remote_for(storage, packages[1])
|
127
|
-
|
128
|
-
|
129
|
-
model = h_set_trigger(trigger)
|
130
|
-
storage = model.storages.first
|
131
|
-
expect do
|
132
|
-
model.perform!
|
133
|
-
end.not_to raise_error
|
134
|
-
|
135
|
-
Backup::Logger.has_warnings?.should be_true
|
136
|
-
|
137
|
-
package = model.package
|
138
|
-
package.filenames.count.should == 1
|
139
|
-
packages << package
|
140
|
-
|
141
|
-
check_remote_for(storage, packages[1])
|
142
|
-
clean_remote!(storage, packages[1])
|
143
|
-
|
144
|
-
check_remote_for(storage, packages[2])
|
145
|
-
clean_remote!(storage, packages[2])
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
end # describe 'Storage::SCP Cycling'
|
150
|
-
|
151
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe 'Storage::Local' do
|
6
|
-
let(:trigger) { 'archive_local' }
|
7
|
-
|
8
|
-
def archive_file_for(model)
|
9
|
-
File.join(
|
10
|
-
Backup::SpecLive::TMP_PATH,
|
11
|
-
"#{model.trigger}", model.time, "#{model.trigger}.tar"
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should store a local archive' do
|
16
|
-
model = h_set_trigger(trigger)
|
17
|
-
model.perform!
|
18
|
-
File.exist?(archive_file_for(model)).should be_true
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'Storage::Local Cycling' do
|
22
|
-
|
23
|
-
context 'when archives exceed `keep` setting' do
|
24
|
-
it 'should remove the oldest archive' do
|
25
|
-
archives = []
|
26
|
-
|
27
|
-
model = h_set_trigger(trigger)
|
28
|
-
model.perform!
|
29
|
-
archives << archive_file_for(model)
|
30
|
-
sleep 1
|
31
|
-
|
32
|
-
model = h_set_trigger(trigger)
|
33
|
-
model.perform!
|
34
|
-
archives << archive_file_for(model)
|
35
|
-
sleep 1
|
36
|
-
|
37
|
-
model = h_set_trigger(trigger)
|
38
|
-
model.perform!
|
39
|
-
archives << archive_file_for(model)
|
40
|
-
|
41
|
-
File.exist?(archives[0]).should be_false
|
42
|
-
File.exist?(archives[1]).should be_true
|
43
|
-
File.exist?(archives[2]).should be_true
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'when an archive to be removed does not exist' do
|
48
|
-
it 'should log a warning and continue' do
|
49
|
-
archives = []
|
50
|
-
|
51
|
-
model = h_set_trigger(trigger)
|
52
|
-
model.perform!
|
53
|
-
archives << archive_file_for(model)
|
54
|
-
sleep 1
|
55
|
-
|
56
|
-
model = h_set_trigger(trigger)
|
57
|
-
model.perform!
|
58
|
-
archives << archive_file_for(model)
|
59
|
-
sleep 1
|
60
|
-
|
61
|
-
File.exist?(archives[0]).should be_true
|
62
|
-
File.exist?(archives[1]).should be_true
|
63
|
-
# remove archive directory cycle! will attempt to remove
|
64
|
-
dir = archives[0].split('/')[0...-1].join('/')
|
65
|
-
h_safety_check(dir)
|
66
|
-
FileUtils.rm_r(dir)
|
67
|
-
File.exist?(archives[0]).should be_false
|
68
|
-
|
69
|
-
expect do
|
70
|
-
model = h_set_trigger(trigger)
|
71
|
-
model.perform!
|
72
|
-
archives << archive_file_for(model)
|
73
|
-
end.not_to raise_error
|
74
|
-
|
75
|
-
Backup::Logger.has_warnings?.should be_true
|
76
|
-
|
77
|
-
File.exist?(archives[1]).should be_true
|
78
|
-
File.exist?(archives[2]).should be_true
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
end # describe 'Storage::Local Cycling'
|
83
|
-
end
|
@@ -1,193 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe 'Storage::SCP',
|
6
|
-
:if => Backup::SpecLive::CONFIG['storage']['scp']['specs_enabled'] do
|
7
|
-
let(:trigger) { 'archive_scp' }
|
8
|
-
|
9
|
-
def remote_files_for(storage, package)
|
10
|
-
remote_path = storage.send(:remote_path_for, package)
|
11
|
-
|
12
|
-
files = []
|
13
|
-
storage.send(:transferred_files_for, package) do |local_file, remote_file|
|
14
|
-
files << File.join(remote_path, remote_file)
|
15
|
-
end
|
16
|
-
files
|
17
|
-
end
|
18
|
-
|
19
|
-
def check_remote_for(storage, files)
|
20
|
-
if (storage.username == Backup::Config.user) &&
|
21
|
-
(storage.ip == 'localhost')
|
22
|
-
files.each do |file|
|
23
|
-
if !File.exist?(file)
|
24
|
-
return false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
true
|
28
|
-
else
|
29
|
-
errors = []
|
30
|
-
storage.send(:connection) do |ssh|
|
31
|
-
files.each do |file|
|
32
|
-
ssh.exec!("ls '#{file}'") do |ch, stream, data|
|
33
|
-
errors << data if stream == :stderr
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
errors.empty?
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def clean_remote!(storage, package)
|
42
|
-
return if (storage.username == Backup::Config.user) &&
|
43
|
-
(storage.ip == 'localhost') &&
|
44
|
-
(storage.path == Backup::SpecLive::TMP_PATH)
|
45
|
-
|
46
|
-
remote_path = storage.send(:remote_path_for, package)
|
47
|
-
h_safety_check(remote_path)
|
48
|
-
storage.send(:connection) do |ssh|
|
49
|
-
ssh.exec!("rm -r '#{remote_path}'")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should store the archive on the remote' do
|
54
|
-
model = h_set_trigger(trigger)
|
55
|
-
|
56
|
-
model.perform!
|
57
|
-
|
58
|
-
storage = model.storages.first
|
59
|
-
package = model.package
|
60
|
-
files = remote_files_for(storage, package)
|
61
|
-
files.count.should == 1
|
62
|
-
|
63
|
-
check_remote_for(storage, files).should be_true
|
64
|
-
|
65
|
-
clean_remote!(storage, package)
|
66
|
-
end
|
67
|
-
|
68
|
-
describe 'Storage::SCP Cycling' do
|
69
|
-
context 'when archives exceed `keep` setting' do
|
70
|
-
it 'should remove the oldest archive' do
|
71
|
-
packages = []
|
72
|
-
|
73
|
-
model = h_set_trigger(trigger)
|
74
|
-
storage = model.storages.first
|
75
|
-
model.perform!
|
76
|
-
package = model.package
|
77
|
-
package.filenames.count.should == 1
|
78
|
-
packages << package
|
79
|
-
sleep 1
|
80
|
-
|
81
|
-
check_remote_for(
|
82
|
-
storage, remote_files_for(storage, packages[0])
|
83
|
-
).should be_true
|
84
|
-
|
85
|
-
model = h_set_trigger(trigger)
|
86
|
-
storage = model.storages.first
|
87
|
-
model.perform!
|
88
|
-
package = model.package
|
89
|
-
package.filenames.count.should == 1
|
90
|
-
packages << package
|
91
|
-
sleep 1
|
92
|
-
|
93
|
-
check_remote_for(
|
94
|
-
storage, remote_files_for(storage, packages[1])
|
95
|
-
).should be_true
|
96
|
-
|
97
|
-
model = h_set_trigger(trigger)
|
98
|
-
storage = model.storages.first
|
99
|
-
model.perform!
|
100
|
-
package = model.package
|
101
|
-
package.filenames.count.should == 1
|
102
|
-
packages << package
|
103
|
-
|
104
|
-
check_remote_for(
|
105
|
-
storage, remote_files_for(storage, packages[2])
|
106
|
-
).should be_true
|
107
|
-
clean_remote!(storage, packages[2])
|
108
|
-
|
109
|
-
check_remote_for(
|
110
|
-
storage, remote_files_for(storage, packages[1])
|
111
|
-
).should be_true
|
112
|
-
clean_remote!(storage, packages[1])
|
113
|
-
|
114
|
-
check_remote_for(
|
115
|
-
storage, remote_files_for(storage, packages[0])
|
116
|
-
).should be_false
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'when an archive to be removed does not exist' do
|
121
|
-
it 'should log a warning and continue' do
|
122
|
-
packages = []
|
123
|
-
|
124
|
-
model = h_set_trigger(trigger)
|
125
|
-
storage = model.storages.first
|
126
|
-
model.perform!
|
127
|
-
package = model.package
|
128
|
-
package.filenames.count.should == 1
|
129
|
-
packages << package
|
130
|
-
sleep 1
|
131
|
-
|
132
|
-
check_remote_for(
|
133
|
-
storage, remote_files_for(storage, packages[0])
|
134
|
-
).should be_true
|
135
|
-
|
136
|
-
model = h_set_trigger(trigger)
|
137
|
-
storage = model.storages.first
|
138
|
-
model.perform!
|
139
|
-
package = model.package
|
140
|
-
package.filenames.count.should == 1
|
141
|
-
packages << package
|
142
|
-
|
143
|
-
check_remote_for(
|
144
|
-
storage, remote_files_for(storage, packages[1])
|
145
|
-
).should be_true
|
146
|
-
|
147
|
-
# remove archive directory cycle! will attempt to remove
|
148
|
-
|
149
|
-
if (storage.username == Backup::Config.user) &&
|
150
|
-
(storage.ip == 'localhost')
|
151
|
-
remote_path = storage.send(:remote_path_for, packages[0])
|
152
|
-
h_safety_check(remote_path)
|
153
|
-
FileUtils.rm_r(remote_path)
|
154
|
-
else
|
155
|
-
clean_remote!(storage, packages[0])
|
156
|
-
end
|
157
|
-
|
158
|
-
check_remote_for(
|
159
|
-
storage, remote_files_for(storage, packages[0])
|
160
|
-
).should be_false
|
161
|
-
|
162
|
-
check_remote_for(
|
163
|
-
storage, remote_files_for(storage, packages[1])
|
164
|
-
).should be_true
|
165
|
-
|
166
|
-
|
167
|
-
model = h_set_trigger(trigger)
|
168
|
-
storage = model.storages.first
|
169
|
-
expect do
|
170
|
-
model.perform!
|
171
|
-
end.not_to raise_error
|
172
|
-
|
173
|
-
Backup::Logger.has_warnings?.should be_true
|
174
|
-
|
175
|
-
package = model.package
|
176
|
-
package.filenames.count.should == 1
|
177
|
-
packages << package
|
178
|
-
|
179
|
-
check_remote_for(
|
180
|
-
storage, remote_files_for(storage, packages[1])
|
181
|
-
).should be_true
|
182
|
-
clean_remote!(storage, packages[1])
|
183
|
-
|
184
|
-
check_remote_for(
|
185
|
-
storage, remote_files_for(storage, packages[2])
|
186
|
-
).should be_true
|
187
|
-
clean_remote!(storage, packages[2])
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
end # describe 'Storage::SCP Cycling'
|
192
|
-
|
193
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe 'Syncer::Cloud::S3 - No Concurrency',
|
6
|
-
:if => Backup::SpecLive::CONFIG['syncer']['cloud']['s3']['specs_enabled'] do
|
7
|
-
let(:trigger) { 'syncer_cloud_s3' }
|
8
|
-
let(:model) { h_set_trigger(trigger) }
|
9
|
-
|
10
|
-
before do
|
11
|
-
model # trigger model initialization so Fog is available
|
12
|
-
create_sync_files
|
13
|
-
clean_remote
|
14
|
-
end
|
15
|
-
|
16
|
-
after do
|
17
|
-
clean_sync_dir
|
18
|
-
clean_remote
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should work' do
|
22
|
-
model.perform!
|
23
|
-
remote_files.map {|file| [file.key, file.etag] }.sort.should == [
|
24
|
-
["backups/dir_a/one.file", "d3b07384d113edec49eaa6238ad5ff00"],
|
25
|
-
["backups/dir_b/dir_c/three.file", "d3b07384d113edec49eaa6238ad5ff00"],
|
26
|
-
["backups/dir_b/two.file", "d3b07384d113edec49eaa6238ad5ff00"]
|
27
|
-
]
|
28
|
-
|
29
|
-
update_sync_files
|
30
|
-
|
31
|
-
model.perform!
|
32
|
-
remote_files.map {|file| [file.key, file.etag] }.sort.should == [
|
33
|
-
["backups/dir_a/dir_d/two.new", "14758f1afd44c09b7992073ccf00b43d"],
|
34
|
-
["backups/dir_a/one.file", "14758f1afd44c09b7992073ccf00b43d"],
|
35
|
-
["backups/dir_b/dir_c/three.file", "d3b07384d113edec49eaa6238ad5ff00"],
|
36
|
-
["backups/dir_b/one.new", "14758f1afd44c09b7992073ccf00b43d"]
|
37
|
-
]
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
##
|
43
|
-
# Initial Files are MD5: d3b07384d113edec49eaa6238ad5ff00
|
44
|
-
#
|
45
|
-
# ├── dir_a
|
46
|
-
# │ └── one.file
|
47
|
-
# └── dir_b
|
48
|
-
# ├── dir_c
|
49
|
-
# │ └── three.file
|
50
|
-
# ├── bad\xFFfile
|
51
|
-
# └── two.file
|
52
|
-
def create_sync_files
|
53
|
-
clean_sync_dir
|
54
|
-
|
55
|
-
%w{ dir_a dir_b/dir_c }.each do |dir|
|
56
|
-
path = File.join(Backup::SpecLive::SYNC_PATH, dir)
|
57
|
-
FileUtils.mkdir_p(path)
|
58
|
-
end
|
59
|
-
|
60
|
-
%W{ dir_a/one.file
|
61
|
-
dir_b/two.file
|
62
|
-
dir_b/bad\xFFfile
|
63
|
-
dir_b/dir_c/three.file }.each do |file|
|
64
|
-
path = File.join(Backup::SpecLive::SYNC_PATH, file)
|
65
|
-
File.open(path, 'w') {|file| file.puts 'foo' }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
##
|
70
|
-
# Added/Updated Files are MD5: 14758f1afd44c09b7992073ccf00b43d
|
71
|
-
#
|
72
|
-
# ├── dir_a
|
73
|
-
# │ ├── dir_d (add)
|
74
|
-
# │ │ └── two.new (add)
|
75
|
-
# │ └── one.file (update)
|
76
|
-
# └── dir_b
|
77
|
-
# ├── dir_c
|
78
|
-
# │ └── three.file
|
79
|
-
# ├── bad\377file
|
80
|
-
# ├── one.new (add)
|
81
|
-
# └── two.file (remove)
|
82
|
-
def update_sync_files
|
83
|
-
FileUtils.mkdir_p(File.join(Backup::SpecLive::SYNC_PATH, 'dir_a/dir_d'))
|
84
|
-
%w{ dir_a/one.file
|
85
|
-
dir_b/one.new
|
86
|
-
dir_a/dir_d/two.new }.each do |file|
|
87
|
-
path = File.join(Backup::SpecLive::SYNC_PATH, file)
|
88
|
-
File.open(path, 'w') {|file| file.puts 'foobar' }
|
89
|
-
end
|
90
|
-
|
91
|
-
path = File.join(Backup::SpecLive::SYNC_PATH, 'dir_b/two.file')
|
92
|
-
h_safety_check(path)
|
93
|
-
FileUtils.rm(path)
|
94
|
-
end
|
95
|
-
|
96
|
-
def clean_sync_dir
|
97
|
-
path = Backup::SpecLive::SYNC_PATH
|
98
|
-
if File.directory?(path)
|
99
|
-
h_safety_check(path)
|
100
|
-
FileUtils.rm_r(path)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# use a new connection for each request
|
105
|
-
def connection
|
106
|
-
@opts = Backup::SpecLive::CONFIG['syncer']['cloud']['s3']
|
107
|
-
Fog::Storage.new(
|
108
|
-
:provider => 'AWS',
|
109
|
-
:aws_access_key_id => @opts['access_key_id'],
|
110
|
-
:aws_secret_access_key => @opts['secret_access_key'],
|
111
|
-
:region => @opts['region']
|
112
|
-
)
|
113
|
-
end
|
114
|
-
|
115
|
-
def remote_files
|
116
|
-
bucket = connection.directories.get(@opts['bucket'])
|
117
|
-
bucket.files.all(:prefix => 'backups')
|
118
|
-
end
|
119
|
-
|
120
|
-
def clean_remote
|
121
|
-
remote_files.each {|file| file.destroy }
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|