backup 3.0.23 → 3.0.24
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/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
data/spec/storage/s3_spec.rb
CHANGED
|
@@ -17,36 +17,69 @@ describe Backup::Storage::S3 do
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
it 'should be a subclass of Storage::Base' do
|
|
21
|
+
Backup::Storage::S3.
|
|
22
|
+
superclass.should == Backup::Storage::Base
|
|
23
|
+
end
|
|
24
|
+
|
|
20
25
|
describe '#initialize' do
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
storage
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
storage.
|
|
26
|
+
after { Backup::Storage::S3.clear_defaults! }
|
|
27
|
+
|
|
28
|
+
it 'should load pre-configured defaults through Base' do
|
|
29
|
+
Backup::Storage::S3.any_instance.expects(:load_defaults!)
|
|
30
|
+
storage
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should pass the model reference to Base' do
|
|
34
|
+
storage.instance_variable_get(:@model).should == model
|
|
30
35
|
end
|
|
31
36
|
|
|
32
|
-
it 'should
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
it 'should pass the storage_id to Base' do
|
|
38
|
+
storage = Backup::Storage::S3.new(model, 'my_storage_id')
|
|
39
|
+
storage.storage_id.should == 'my_storage_id'
|
|
35
40
|
end
|
|
36
41
|
|
|
37
|
-
context 'when
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
context 'when no pre-configured defaults have been set' do
|
|
43
|
+
it 'should use the values given' do
|
|
44
|
+
storage.access_key_id.should == 'my_access_key_id'
|
|
45
|
+
storage.secret_access_key.should == 'my_secret_access_key'
|
|
46
|
+
storage.bucket.should == 'my-bucket'
|
|
47
|
+
storage.path.should == 'backups'
|
|
48
|
+
storage.region.should == 'us-east-1'
|
|
49
|
+
|
|
50
|
+
storage.storage_id.should be_nil
|
|
51
|
+
storage.keep.should == 5
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should use default values if none are given' do
|
|
55
|
+
storage = Backup::Storage::S3.new(model)
|
|
56
|
+
|
|
57
|
+
storage.access_key_id.should be_nil
|
|
58
|
+
storage.secret_access_key.should be_nil
|
|
59
|
+
storage.bucket.should be_nil
|
|
60
|
+
storage.path.should == 'backups'
|
|
61
|
+
storage.region.should be_nil
|
|
62
|
+
|
|
63
|
+
storage.storage_id.should be_nil
|
|
64
|
+
storage.keep.should be_nil
|
|
65
|
+
end
|
|
66
|
+
end # context 'when no pre-configured defaults have been set'
|
|
67
|
+
|
|
68
|
+
context 'when pre-configured defaults have been set' do
|
|
69
|
+
before do
|
|
70
|
+
Backup::Storage::S3.defaults do |s|
|
|
71
|
+
s.access_key_id = 'some_access_key_id'
|
|
72
|
+
s.secret_access_key = 'some_secret_access_key'
|
|
73
|
+
s.bucket = 'some-bucket'
|
|
74
|
+
s.path = 'some_path'
|
|
75
|
+
s.region = 'some_region'
|
|
76
|
+
s.keep = 15
|
|
48
77
|
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'should use pre-configured defaults' do
|
|
49
81
|
storage = Backup::Storage::S3.new(model)
|
|
82
|
+
|
|
50
83
|
storage.access_key_id.should == 'some_access_key_id'
|
|
51
84
|
storage.secret_access_key.should == 'some_secret_access_key'
|
|
52
85
|
storage.bucket.should == 'some-bucket'
|
|
@@ -57,22 +90,14 @@ describe Backup::Storage::S3 do
|
|
|
57
90
|
storage.keep.should == 15
|
|
58
91
|
end
|
|
59
92
|
|
|
60
|
-
it 'should override
|
|
61
|
-
Backup::
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
end
|
|
69
|
-
storage = Backup::Storage::S3.new(model) do |s3|
|
|
70
|
-
s3.access_key_id = 'new_access_key_id'
|
|
71
|
-
s3.secret_access_key = 'new_secret_access_key'
|
|
72
|
-
s3.bucket = 'new-bucket'
|
|
73
|
-
s3.path = 'new_path'
|
|
74
|
-
s3.region = 'new_region'
|
|
75
|
-
s3.keep = 10
|
|
93
|
+
it 'should override pre-configured defaults' do
|
|
94
|
+
storage = Backup::Storage::S3.new(model) do |s|
|
|
95
|
+
s.access_key_id = 'new_access_key_id'
|
|
96
|
+
s.secret_access_key = 'new_secret_access_key'
|
|
97
|
+
s.bucket = 'new-bucket'
|
|
98
|
+
s.path = 'new_path'
|
|
99
|
+
s.region = 'new_region'
|
|
100
|
+
s.keep = 10
|
|
76
101
|
end
|
|
77
102
|
|
|
78
103
|
storage.access_key_id.should == 'new_access_key_id'
|
|
@@ -84,8 +109,7 @@ describe Backup::Storage::S3 do
|
|
|
84
109
|
storage.storage_id.should be_nil
|
|
85
110
|
storage.keep.should == 10
|
|
86
111
|
end
|
|
87
|
-
end # context 'when
|
|
88
|
-
|
|
112
|
+
end # context 'when pre-configured defaults have been set'
|
|
89
113
|
end # describe '#initialize'
|
|
90
114
|
|
|
91
115
|
describe '#provider' do
|
data/spec/storage/scp_spec.rb
CHANGED
|
@@ -13,21 +13,26 @@ describe Backup::Storage::SCP do
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
it 'should be a subclass of Storage::Base' do
|
|
17
|
+
Backup::Storage::SCP.
|
|
18
|
+
superclass.should == Backup::Storage::Base
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
describe '#initialize' do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
storage
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
storage.
|
|
22
|
+
after { Backup::Storage::SCP.clear_defaults! }
|
|
23
|
+
|
|
24
|
+
it 'should load pre-configured defaults through Base' do
|
|
25
|
+
Backup::Storage::SCP.any_instance.expects(:load_defaults!)
|
|
26
|
+
storage
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should pass the model reference to Base' do
|
|
30
|
+
storage.instance_variable_get(:@model).should == model
|
|
26
31
|
end
|
|
27
32
|
|
|
28
|
-
it 'should
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
it 'should pass the storage_id to Base' do
|
|
34
|
+
storage = Backup::Storage::SCP.new(model, 'my_storage_id')
|
|
35
|
+
storage.storage_id.should == 'my_storage_id'
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
it 'should remove any preceeding tilde and slash from the path' do
|
|
@@ -37,19 +42,47 @@ describe Backup::Storage::SCP do
|
|
|
37
42
|
storage.path.should == 'my_backups/path'
|
|
38
43
|
end
|
|
39
44
|
|
|
40
|
-
context 'when
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
context 'when no pre-configured defaults have been set' do
|
|
46
|
+
it 'should use the values given' do
|
|
47
|
+
storage.username.should == 'my_username'
|
|
48
|
+
storage.password.should == 'my_password'
|
|
49
|
+
storage.ip.should == '123.45.678.90'
|
|
50
|
+
storage.port.should == 22
|
|
51
|
+
storage.path.should == 'backups'
|
|
52
|
+
|
|
53
|
+
storage.storage_id.should be_nil
|
|
54
|
+
storage.keep.should == 5
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should use default values if none are given' do
|
|
58
|
+
storage = Backup::Storage::SCP.new(model)
|
|
59
|
+
|
|
60
|
+
storage.username.should be_nil
|
|
61
|
+
storage.password.should be_nil
|
|
62
|
+
storage.ip.should be_nil
|
|
63
|
+
storage.port.should == 22
|
|
64
|
+
storage.path.should == 'backups'
|
|
65
|
+
|
|
66
|
+
storage.storage_id.should be_nil
|
|
67
|
+
storage.keep.should be_nil
|
|
68
|
+
end
|
|
69
|
+
end # context 'when no pre-configured defaults have been set'
|
|
70
|
+
|
|
71
|
+
context 'when pre-configured defaults have been set' do
|
|
72
|
+
before do
|
|
73
|
+
Backup::Storage::SCP.defaults do |s|
|
|
74
|
+
s.username = 'some_username'
|
|
75
|
+
s.password = 'some_password'
|
|
76
|
+
s.ip = 'some_ip'
|
|
77
|
+
s.port = 'some_port'
|
|
78
|
+
s.path = 'some_path'
|
|
79
|
+
s.keep = 'some_keep'
|
|
51
80
|
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'should use pre-configured defaults' do
|
|
52
84
|
storage = Backup::Storage::SCP.new(model)
|
|
85
|
+
|
|
53
86
|
storage.username.should == 'some_username'
|
|
54
87
|
storage.password.should == 'some_password'
|
|
55
88
|
storage.ip.should == 'some_ip'
|
|
@@ -60,22 +93,14 @@ describe Backup::Storage::SCP do
|
|
|
60
93
|
storage.keep.should == 'some_keep'
|
|
61
94
|
end
|
|
62
95
|
|
|
63
|
-
it 'should override
|
|
64
|
-
Backup::
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
storage = Backup::Storage::SCP.new(model) do |scp|
|
|
73
|
-
scp.username = 'new_username'
|
|
74
|
-
scp.password = 'new_password'
|
|
75
|
-
scp.ip = 'new_ip'
|
|
76
|
-
scp.port = 'new_port'
|
|
77
|
-
scp.path = 'new_path'
|
|
78
|
-
scp.keep = 'new_keep'
|
|
96
|
+
it 'should override pre-configured defaults' do
|
|
97
|
+
storage = Backup::Storage::SCP.new(model) do |s|
|
|
98
|
+
s.username = 'new_username'
|
|
99
|
+
s.password = 'new_password'
|
|
100
|
+
s.ip = 'new_ip'
|
|
101
|
+
s.port = 'new_port'
|
|
102
|
+
s.path = 'new_path'
|
|
103
|
+
s.keep = 'new_keep'
|
|
79
104
|
end
|
|
80
105
|
|
|
81
106
|
storage.username.should == 'new_username'
|
|
@@ -87,8 +112,7 @@ describe Backup::Storage::SCP do
|
|
|
87
112
|
storage.storage_id.should be_nil
|
|
88
113
|
storage.keep.should == 'new_keep'
|
|
89
114
|
end
|
|
90
|
-
end # context 'when
|
|
91
|
-
|
|
115
|
+
end # context 'when pre-configured defaults have been set'
|
|
92
116
|
end # describe '#initialize'
|
|
93
117
|
|
|
94
118
|
describe '#connection' do
|
data/spec/storage/sftp_spec.rb
CHANGED
|
@@ -13,21 +13,26 @@ describe Backup::Storage::SFTP do
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
it 'should be a subclass of Storage::Base' do
|
|
17
|
+
Backup::Storage::SFTP.
|
|
18
|
+
superclass.should == Backup::Storage::Base
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
describe '#initialize' do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
storage
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
storage.
|
|
22
|
+
after { Backup::Storage::SFTP.clear_defaults! }
|
|
23
|
+
|
|
24
|
+
it 'should load pre-configured defaults through Base' do
|
|
25
|
+
Backup::Storage::SFTP.any_instance.expects(:load_defaults!)
|
|
26
|
+
storage
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should pass the model reference to Base' do
|
|
30
|
+
storage.instance_variable_get(:@model).should == model
|
|
26
31
|
end
|
|
27
32
|
|
|
28
|
-
it 'should
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
it 'should pass the storage_id to Base' do
|
|
34
|
+
storage = Backup::Storage::SFTP.new(model, 'my_storage_id')
|
|
35
|
+
storage.storage_id.should == 'my_storage_id'
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
it 'should remove any preceeding tilde and slash from the path' do
|
|
@@ -37,19 +42,47 @@ describe Backup::Storage::SFTP do
|
|
|
37
42
|
storage.path.should == 'my_backups/path'
|
|
38
43
|
end
|
|
39
44
|
|
|
40
|
-
context 'when
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
context 'when no pre-configured defaults have been set' do
|
|
46
|
+
it 'should use the values given' do
|
|
47
|
+
storage.username.should == 'my_username'
|
|
48
|
+
storage.password.should == 'my_password'
|
|
49
|
+
storage.ip.should == '123.45.678.90'
|
|
50
|
+
storage.port.should == 22
|
|
51
|
+
storage.path.should == 'backups'
|
|
52
|
+
|
|
53
|
+
storage.storage_id.should be_nil
|
|
54
|
+
storage.keep.should == 5
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should use default values if none are given' do
|
|
58
|
+
storage = Backup::Storage::SFTP.new(model)
|
|
59
|
+
|
|
60
|
+
storage.username.should be_nil
|
|
61
|
+
storage.password.should be_nil
|
|
62
|
+
storage.ip.should be_nil
|
|
63
|
+
storage.port.should == 22
|
|
64
|
+
storage.path.should == 'backups'
|
|
65
|
+
|
|
66
|
+
storage.storage_id.should be_nil
|
|
67
|
+
storage.keep.should be_nil
|
|
68
|
+
end
|
|
69
|
+
end # context 'when no pre-configured defaults have been set'
|
|
70
|
+
|
|
71
|
+
context 'when pre-configured defaults have been set' do
|
|
72
|
+
before do
|
|
73
|
+
Backup::Storage::SFTP.defaults do |s|
|
|
74
|
+
s.username = 'some_username'
|
|
75
|
+
s.password = 'some_password'
|
|
76
|
+
s.ip = 'some_ip'
|
|
77
|
+
s.port = 'some_port'
|
|
78
|
+
s.path = 'some_path'
|
|
79
|
+
s.keep = 'some_keep'
|
|
51
80
|
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'should use pre-configured defaults' do
|
|
52
84
|
storage = Backup::Storage::SFTP.new(model)
|
|
85
|
+
|
|
53
86
|
storage.username.should == 'some_username'
|
|
54
87
|
storage.password.should == 'some_password'
|
|
55
88
|
storage.ip.should == 'some_ip'
|
|
@@ -60,22 +93,14 @@ describe Backup::Storage::SFTP do
|
|
|
60
93
|
storage.keep.should == 'some_keep'
|
|
61
94
|
end
|
|
62
95
|
|
|
63
|
-
it 'should override
|
|
64
|
-
Backup::
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
storage = Backup::Storage::SFTP.new(model) do |sftp|
|
|
73
|
-
sftp.username = 'new_username'
|
|
74
|
-
sftp.password = 'new_password'
|
|
75
|
-
sftp.ip = 'new_ip'
|
|
76
|
-
sftp.port = 'new_port'
|
|
77
|
-
sftp.path = 'new_path'
|
|
78
|
-
sftp.keep = 'new_keep'
|
|
96
|
+
it 'should override pre-configured defaults' do
|
|
97
|
+
storage = Backup::Storage::SFTP.new(model) do |s|
|
|
98
|
+
s.username = 'new_username'
|
|
99
|
+
s.password = 'new_password'
|
|
100
|
+
s.ip = 'new_ip'
|
|
101
|
+
s.port = 'new_port'
|
|
102
|
+
s.path = 'new_path'
|
|
103
|
+
s.keep = 'new_keep'
|
|
79
104
|
end
|
|
80
105
|
|
|
81
106
|
storage.username.should == 'new_username'
|
|
@@ -87,8 +112,7 @@ describe Backup::Storage::SFTP do
|
|
|
87
112
|
storage.storage_id.should be_nil
|
|
88
113
|
storage.keep.should == 'new_keep'
|
|
89
114
|
end
|
|
90
|
-
end # context 'when
|
|
91
|
-
|
|
115
|
+
end # context 'when pre-configured defaults have been set'
|
|
92
116
|
end # describe '#initialize'
|
|
93
117
|
|
|
94
118
|
describe '#connection' do
|
data/spec/syncer/base_spec.rb
CHANGED
|
@@ -3,15 +3,102 @@
|
|
|
3
3
|
require File.expand_path('../../spec_helper.rb', __FILE__)
|
|
4
4
|
|
|
5
5
|
describe Backup::Syncer::Base do
|
|
6
|
-
let(:
|
|
7
|
-
let(:syncer) { base.new }
|
|
6
|
+
let(:syncer) { Backup::Syncer::Base.new }
|
|
8
7
|
|
|
9
8
|
it 'should include CLI::Helpers' do
|
|
10
|
-
|
|
9
|
+
Backup::Syncer::Base.
|
|
10
|
+
include?(Backup::CLI::Helpers).should be_true
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it 'should include Configuration::Helpers' do
|
|
14
|
-
|
|
14
|
+
Backup::Syncer::Base.
|
|
15
|
+
include?(Backup::Configuration::Helpers).should be_true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe '#initialize' do
|
|
19
|
+
after { Backup::Syncer::Base.clear_defaults! }
|
|
20
|
+
|
|
21
|
+
it 'should load pre-configured defaults through Base' do
|
|
22
|
+
Backup::Syncer::Base.any_instance.expects(:load_defaults!)
|
|
23
|
+
syncer
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should establish a new array for @directories' do
|
|
27
|
+
syncer.directories.should == []
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context 'when no pre-configured defaults have been set' do
|
|
31
|
+
it 'should set default values' do
|
|
32
|
+
syncer.path.should == 'backups'
|
|
33
|
+
syncer.mirror.should == false
|
|
34
|
+
end
|
|
35
|
+
end # context 'when no pre-configured defaults have been set'
|
|
36
|
+
|
|
37
|
+
context 'when pre-configured defaults have been set' do
|
|
38
|
+
before do
|
|
39
|
+
Backup::Syncer::Base.defaults do |s|
|
|
40
|
+
s.path = 'some_path'
|
|
41
|
+
s.mirror = 'some_mirror'
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should use pre-configured defaults' do
|
|
46
|
+
syncer.path.should == 'some_path'
|
|
47
|
+
syncer.mirror.should == 'some_mirror'
|
|
48
|
+
end
|
|
49
|
+
end # context 'when pre-configured defaults have been set'
|
|
50
|
+
end # describe '#initialize'
|
|
51
|
+
|
|
52
|
+
describe '#directories' do
|
|
53
|
+
before do
|
|
54
|
+
syncer.instance_variable_set(
|
|
55
|
+
:@directories, ['/some/directory', '/another/directory']
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context 'when no block is given' do
|
|
60
|
+
it 'should return @directories' do
|
|
61
|
+
syncer.directories.should ==
|
|
62
|
+
['/some/directory', '/another/directory']
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context 'when a block is given' do
|
|
67
|
+
it 'should evalute the block, allowing #add to add directories' do
|
|
68
|
+
syncer.directories do
|
|
69
|
+
add '/new/path'
|
|
70
|
+
add '/another/new/path'
|
|
71
|
+
end
|
|
72
|
+
syncer.directories.should == [
|
|
73
|
+
'/some/directory',
|
|
74
|
+
'/another/directory',
|
|
75
|
+
'/new/path',
|
|
76
|
+
'/another/new/path'
|
|
77
|
+
]
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end # describe '#directories'
|
|
81
|
+
|
|
82
|
+
describe '#add' do
|
|
83
|
+
before do
|
|
84
|
+
syncer.instance_variable_set(
|
|
85
|
+
:@directories, ['/some/directory', '/another/directory']
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'should add the given path to @directories' do
|
|
90
|
+
syncer.add '/my/path'
|
|
91
|
+
syncer.directories.should ==
|
|
92
|
+
['/some/directory', '/another/directory', '/my/path']
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Note: Each Syncer should handle this as needed.
|
|
96
|
+
# For example, expanding these here would break RSync::Pull
|
|
97
|
+
it 'should not expand the given paths' do
|
|
98
|
+
syncer.add 'relative/path'
|
|
99
|
+
syncer.directories.should ==
|
|
100
|
+
['/some/directory', '/another/directory', 'relative/path']
|
|
101
|
+
end
|
|
15
102
|
end
|
|
16
103
|
|
|
17
104
|
describe '#syncer_name' do
|