backup 3.0.20 → 3.0.21
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -5
- data/Gemfile.lock +46 -50
- data/README.md +54 -27
- data/lib/backup.rb +16 -39
- data/lib/backup/archive.rb +42 -18
- data/lib/backup/cleaner.rb +110 -25
- data/lib/backup/cli/helpers.rb +17 -32
- data/lib/backup/cli/utility.rb +46 -107
- data/lib/backup/compressor/base.rb +14 -2
- data/lib/backup/compressor/bzip2.rb +10 -24
- data/lib/backup/compressor/gzip.rb +10 -24
- data/lib/backup/compressor/lzma.rb +10 -23
- data/lib/backup/compressor/pbzip2.rb +12 -32
- data/lib/backup/config.rb +171 -0
- data/lib/backup/configuration/compressor/base.rb +1 -2
- data/lib/backup/configuration/compressor/pbzip2.rb +4 -4
- data/lib/backup/configuration/database/base.rb +2 -1
- data/lib/backup/configuration/database/mongodb.rb +8 -0
- data/lib/backup/configuration/database/mysql.rb +4 -0
- data/lib/backup/configuration/database/postgresql.rb +4 -0
- data/lib/backup/configuration/database/redis.rb +4 -0
- data/lib/backup/configuration/database/riak.rb +5 -1
- data/lib/backup/configuration/encryptor/base.rb +1 -2
- data/lib/backup/configuration/encryptor/open_ssl.rb +1 -1
- data/lib/backup/configuration/helpers.rb +7 -2
- data/lib/backup/configuration/notifier/base.rb +4 -28
- data/lib/backup/configuration/storage/base.rb +1 -1
- data/lib/backup/configuration/storage/dropbox.rb +14 -4
- data/lib/backup/configuration/syncer/base.rb +10 -0
- data/lib/backup/configuration/syncer/rsync/base.rb +28 -0
- data/lib/backup/configuration/syncer/rsync/local.rb +11 -0
- data/lib/backup/configuration/syncer/rsync/pull.rb +11 -0
- data/lib/backup/configuration/syncer/rsync/push.rb +31 -0
- data/lib/backup/configuration/syncer/s3.rb +0 -4
- data/lib/backup/database/base.rb +25 -7
- data/lib/backup/database/mongodb.rb +112 -75
- data/lib/backup/database/mysql.rb +54 -29
- data/lib/backup/database/postgresql.rb +60 -42
- data/lib/backup/database/redis.rb +61 -39
- data/lib/backup/database/riak.rb +35 -11
- data/lib/backup/dependency.rb +4 -5
- data/lib/backup/encryptor/base.rb +13 -1
- data/lib/backup/encryptor/gpg.rb +39 -39
- data/lib/backup/encryptor/open_ssl.rb +28 -38
- data/lib/backup/logger.rb +20 -11
- data/lib/backup/model.rb +206 -163
- data/lib/backup/notifier/base.rb +27 -25
- data/lib/backup/notifier/campfire.rb +7 -13
- data/lib/backup/notifier/hipchat.rb +28 -28
- data/lib/backup/notifier/mail.rb +24 -26
- data/lib/backup/notifier/presently.rb +10 -18
- data/lib/backup/notifier/prowl.rb +9 -17
- data/lib/backup/notifier/twitter.rb +11 -18
- data/lib/backup/package.rb +47 -0
- data/lib/backup/packager.rb +81 -16
- data/lib/backup/splitter.rb +48 -35
- data/lib/backup/storage/base.rb +44 -172
- data/lib/backup/storage/cloudfiles.rb +31 -46
- data/lib/backup/storage/cycler.rb +117 -0
- data/lib/backup/storage/dropbox.rb +92 -76
- data/lib/backup/storage/ftp.rb +30 -40
- data/lib/backup/storage/local.rb +44 -45
- data/lib/backup/storage/ninefold.rb +55 -49
- data/lib/backup/storage/rsync.rb +49 -56
- data/lib/backup/storage/s3.rb +33 -44
- data/lib/backup/storage/scp.rb +21 -48
- data/lib/backup/storage/sftp.rb +26 -40
- data/lib/backup/syncer/base.rb +7 -0
- data/lib/backup/syncer/rsync/base.rb +78 -0
- data/lib/backup/syncer/rsync/local.rb +53 -0
- data/lib/backup/syncer/rsync/pull.rb +38 -0
- data/lib/backup/syncer/rsync/push.rb +113 -0
- data/lib/backup/syncer/s3.rb +42 -32
- data/lib/backup/version.rb +1 -1
- data/spec/archive_spec.rb +235 -69
- data/spec/cleaner_spec.rb +304 -0
- data/spec/cli/helpers_spec.rb +142 -1
- data/spec/cli/utility_spec.rb +338 -13
- data/spec/compressor/base_spec.rb +31 -0
- data/spec/compressor/bzip2_spec.rb +60 -35
- data/spec/compressor/gzip_spec.rb +60 -35
- data/spec/compressor/lzma_spec.rb +60 -35
- data/spec/compressor/pbzip2_spec.rb +98 -37
- data/spec/config_spec.rb +321 -0
- data/spec/configuration/base_spec.rb +4 -4
- data/spec/configuration/compressor/bzip2_spec.rb +1 -0
- data/spec/configuration/compressor/gzip_spec.rb +1 -0
- data/spec/configuration/compressor/lzma_spec.rb +1 -0
- data/spec/configuration/compressor/pbzip2_spec.rb +32 -0
- data/spec/configuration/database/base_spec.rb +2 -1
- data/spec/configuration/database/mongodb_spec.rb +26 -16
- data/spec/configuration/database/mysql_spec.rb +4 -0
- data/spec/configuration/database/postgresql_spec.rb +4 -0
- data/spec/configuration/database/redis_spec.rb +4 -0
- data/spec/configuration/database/riak_spec.rb +4 -0
- data/spec/configuration/encryptor/gpg_spec.rb +1 -0
- data/spec/configuration/encryptor/open_ssl_spec.rb +1 -0
- data/spec/configuration/notifier/base_spec.rb +32 -0
- data/spec/configuration/notifier/campfire_spec.rb +1 -0
- data/spec/configuration/notifier/hipchat_spec.rb +1 -0
- data/spec/configuration/notifier/mail_spec.rb +1 -0
- data/spec/configuration/notifier/presently_spec.rb +1 -0
- data/spec/configuration/notifier/prowl_spec.rb +1 -0
- data/spec/configuration/notifier/twitter_spec.rb +1 -0
- data/spec/configuration/storage/cloudfiles_spec.rb +1 -0
- data/spec/configuration/storage/dropbox_spec.rb +4 -3
- data/spec/configuration/storage/ftp_spec.rb +1 -0
- data/spec/configuration/storage/local_spec.rb +1 -0
- data/spec/configuration/storage/ninefold_spec.rb +1 -0
- data/spec/configuration/storage/rsync_spec.rb +3 -1
- data/spec/configuration/storage/s3_spec.rb +1 -0
- data/spec/configuration/storage/scp_spec.rb +1 -0
- data/spec/configuration/storage/sftp_spec.rb +1 -0
- data/spec/configuration/syncer/rsync/base_spec.rb +33 -0
- data/spec/configuration/syncer/rsync/local_spec.rb +10 -0
- data/spec/configuration/syncer/rsync/pull_spec.rb +10 -0
- data/spec/configuration/syncer/{rsync_spec.rb → rsync/push_spec.rb} +12 -15
- data/spec/configuration/syncer/s3_spec.rb +2 -3
- data/spec/database/base_spec.rb +35 -20
- data/spec/database/mongodb_spec.rb +298 -119
- data/spec/database/mysql_spec.rb +147 -72
- data/spec/database/postgresql_spec.rb +155 -100
- data/spec/database/redis_spec.rb +200 -97
- data/spec/database/riak_spec.rb +82 -24
- data/spec/dependency_spec.rb +49 -0
- data/spec/encryptor/base_spec.rb +30 -0
- data/spec/encryptor/gpg_spec.rb +105 -28
- data/spec/encryptor/open_ssl_spec.rb +85 -114
- data/spec/logger_spec.rb +74 -8
- data/spec/model_spec.rb +528 -220
- data/spec/notifier/base_spec.rb +89 -0
- data/spec/notifier/campfire_spec.rb +147 -119
- data/spec/notifier/hipchat_spec.rb +140 -145
- data/spec/notifier/mail_spec.rb +190 -248
- data/spec/notifier/presently_spec.rb +147 -282
- data/spec/notifier/prowl_spec.rb +79 -111
- data/spec/notifier/twitter_spec.rb +87 -106
- data/spec/package_spec.rb +61 -0
- data/spec/packager_spec.rb +154 -0
- data/spec/spec_helper.rb +36 -13
- data/spec/splitter_spec.rb +90 -41
- data/spec/storage/base_spec.rb +95 -239
- data/spec/storage/cloudfiles_spec.rb +185 -75
- data/spec/storage/cycler_spec.rb +239 -0
- data/spec/storage/dropbox_spec.rb +318 -87
- data/spec/storage/ftp_spec.rb +165 -152
- data/spec/storage/local_spec.rb +206 -54
- data/spec/storage/ninefold_spec.rb +264 -128
- data/spec/storage/rsync_spec.rb +244 -163
- data/spec/storage/s3_spec.rb +175 -64
- data/spec/storage/scp_spec.rb +156 -150
- data/spec/storage/sftp_spec.rb +153 -135
- data/spec/syncer/base_spec.rb +22 -0
- data/spec/syncer/rsync/base_spec.rb +118 -0
- data/spec/syncer/rsync/local_spec.rb +121 -0
- data/spec/syncer/rsync/pull_spec.rb +90 -0
- data/spec/syncer/rsync/push_spec.rb +327 -0
- data/spec/syncer/s3_spec.rb +180 -91
- data/templates/cli/utility/config +1 -1
- data/templates/cli/utility/database/mongodb +4 -0
- data/templates/cli/utility/database/mysql +3 -0
- data/templates/cli/utility/database/postgresql +3 -0
- data/templates/cli/utility/database/redis +3 -0
- data/templates/cli/utility/database/riak +3 -0
- data/templates/cli/utility/storage/dropbox +4 -1
- data/templates/cli/utility/syncer/rsync_local +12 -0
- data/templates/cli/utility/syncer/{rsync → rsync_pull} +2 -2
- data/templates/cli/utility/syncer/rsync_push +17 -0
- data/templates/storage/dropbox/authorization_url.erb +1 -1
- metadata +42 -17
- data/lib/backup/configuration/syncer/rsync.rb +0 -45
- data/lib/backup/finder.rb +0 -87
- data/lib/backup/storage/object.rb +0 -47
- data/lib/backup/syncer/rsync.rb +0 -152
- data/spec/backup_spec.rb +0 -11
- data/spec/finder_spec.rb +0 -91
- data/spec/storage/object_spec.rb +0 -74
- data/spec/syncer/rsync_spec.rb +0 -195
data/spec/syncer/rsync_spec.rb
DELETED
@@ -1,195 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe Backup::Syncer::RSync do
|
6
|
-
|
7
|
-
let(:rsync) do
|
8
|
-
Backup::Syncer::RSync.new do |rsync|
|
9
|
-
rsync.username = 'my_username'
|
10
|
-
rsync.password = 'my_password'
|
11
|
-
rsync.ip = '123.45.678.90'
|
12
|
-
rsync.port = 22
|
13
|
-
rsync.path = '~/backups/'
|
14
|
-
rsync.mirror = true
|
15
|
-
rsync.compress = true
|
16
|
-
rsync.additional_options = []
|
17
|
-
|
18
|
-
rsync.directories do |directory|
|
19
|
-
directory.add "/some/random/directory"
|
20
|
-
directory.add "/another/random/directory"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
before do
|
26
|
-
Backup::Configuration::Syncer::RSync.clear_defaults!
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should have defined the configuration properly' do
|
30
|
-
rsync.username.should == 'my_username'
|
31
|
-
rsync.password.should =~ /backup-rsync-password/
|
32
|
-
rsync.ip.should == '123.45.678.90'
|
33
|
-
rsync.port.should == "-e 'ssh -p 22'"
|
34
|
-
rsync.path.should == 'backups/'
|
35
|
-
rsync.mirror.should == "--delete"
|
36
|
-
rsync.compress.should == "--compress"
|
37
|
-
|
38
|
-
File.read(rsync.instance_variable_get('@password_file').path).should == 'my_password'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should use the defaults if a particular attribute has not been defined' do
|
42
|
-
Backup::Configuration::Syncer::RSync.defaults do |rsync|
|
43
|
-
rsync.username = 'my_default_username'
|
44
|
-
rsync.password = 'my_default_password'
|
45
|
-
rsync.path = '~/backups'
|
46
|
-
rsync.mirror = false
|
47
|
-
end
|
48
|
-
|
49
|
-
rsync = Backup::Syncer::RSync.new do |rsync|
|
50
|
-
rsync.password = 'my_password'
|
51
|
-
rsync.ip = '123.45.678.90'
|
52
|
-
rsync.compress = false
|
53
|
-
end
|
54
|
-
|
55
|
-
rsync.username.should == 'my_default_username'
|
56
|
-
rsync.password.should =~ /backup-rsync-password/
|
57
|
-
rsync.ip.should == '123.45.678.90'
|
58
|
-
rsync.port.should == "-e 'ssh -p 22'"
|
59
|
-
rsync.mirror.should == nil
|
60
|
-
rsync.compress.should == nil
|
61
|
-
|
62
|
-
File.read(rsync.instance_variable_get('@password_file').path).should == 'my_password'
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should have its own defaults' do
|
66
|
-
rsync = Backup::Syncer::RSync.new
|
67
|
-
rsync.port.should == "-e 'ssh -p 22'"
|
68
|
-
rsync.path.should == 'backups'
|
69
|
-
rsync.compress.should == nil
|
70
|
-
rsync.mirror.should == nil
|
71
|
-
rsync.directories.should == ''
|
72
|
-
rsync.additional_options.should == []
|
73
|
-
end
|
74
|
-
|
75
|
-
describe '#mirror' do
|
76
|
-
context 'when true' do
|
77
|
-
it do
|
78
|
-
rsync.mirror = true
|
79
|
-
rsync.mirror.should == '--delete'
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'when nil/false' do
|
84
|
-
it do
|
85
|
-
rsync.mirror = nil
|
86
|
-
rsync.mirror.should == nil
|
87
|
-
end
|
88
|
-
|
89
|
-
it do
|
90
|
-
rsync.mirror = false
|
91
|
-
rsync.mirror.should == nil
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#compress' do
|
97
|
-
context 'when true' do
|
98
|
-
it do
|
99
|
-
rsync.compress = true
|
100
|
-
rsync.compress.should == '--compress'
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'when nil/false' do
|
105
|
-
it do
|
106
|
-
rsync.compress = nil
|
107
|
-
rsync.compress.should == nil
|
108
|
-
end
|
109
|
-
|
110
|
-
it do
|
111
|
-
rsync.compress = false
|
112
|
-
rsync.compress.should == nil
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe '#archive' do
|
118
|
-
it do
|
119
|
-
rsync.archive.should == '--archive'
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe '#port' do
|
124
|
-
it do
|
125
|
-
rsync.port.should == "-e 'ssh -p 22'"
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe '#directories' do
|
130
|
-
context 'when its empty' do
|
131
|
-
it do
|
132
|
-
rsync.directories = []
|
133
|
-
rsync.directories.should == ''
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'when it has items' do
|
138
|
-
it do
|
139
|
-
rsync.directories = ['directory1', 'directory1/directory2', 'directory1/directory2/directory3']
|
140
|
-
rsync.directories.should == "'directory1' 'directory1/directory2' 'directory1/directory2/directory3'"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe '#options' do
|
146
|
-
it do
|
147
|
-
rsync.options.should == "--archive --delete --compress -e 'ssh -p 22' " +
|
148
|
-
"--password-file='#{rsync.instance_variable_get('@password_file').path}'"
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe '#password' do
|
153
|
-
before do
|
154
|
-
rsync.stubs(:utility).with(:rsync).returns(:rsync)
|
155
|
-
rsync.stubs(:run)
|
156
|
-
end
|
157
|
-
|
158
|
-
it do
|
159
|
-
rsync.password = 'my_password'
|
160
|
-
rsync.expects(:remove_password_file!)
|
161
|
-
|
162
|
-
rsync.perform!
|
163
|
-
end
|
164
|
-
|
165
|
-
it do
|
166
|
-
rsync.password = nil
|
167
|
-
rsync.expects(:remove_password_file!)
|
168
|
-
|
169
|
-
rsync.perform!
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe '#perform' do
|
174
|
-
|
175
|
-
it 'should invoke the rsync command to transfer the files and directories' do
|
176
|
-
Backup::Logger.expects(:message).with("Backup::Syncer::RSync started syncing '/some/random/directory' '/another/random/directory'.")
|
177
|
-
rsync.expects(:utility).with(:rsync).returns(:rsync)
|
178
|
-
rsync.expects(:remove_password_file!)
|
179
|
-
rsync.expects(:run).with("rsync --archive --delete --compress -e 'ssh -p 22' --password-file='#{rsync.instance_variable_get('@password_file').path}' " +
|
180
|
-
"'/some/random/directory' '/another/random/directory' 'my_username@123.45.678.90:backups/'")
|
181
|
-
rsync.perform!
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'should not pass in the --password-file option' do
|
185
|
-
Backup::Logger.expects(:message).with("Backup::Syncer::RSync started syncing '/some/random/directory' '/another/random/directory'.")
|
186
|
-
rsync.password = nil
|
187
|
-
rsync.expects(:utility).with(:rsync).returns(:rsync)
|
188
|
-
rsync.expects(:remove_password_file!)
|
189
|
-
rsync.expects(:run).with("rsync --archive --delete --compress -e 'ssh -p 22' " +
|
190
|
-
"'/some/random/directory' '/another/random/directory' 'my_username@123.45.678.90:backups/'")
|
191
|
-
rsync.perform!
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
end
|