backup 3.0.20 → 3.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/Gemfile +1 -5
  2. data/Gemfile.lock +46 -50
  3. data/README.md +54 -27
  4. data/lib/backup.rb +16 -39
  5. data/lib/backup/archive.rb +42 -18
  6. data/lib/backup/cleaner.rb +110 -25
  7. data/lib/backup/cli/helpers.rb +17 -32
  8. data/lib/backup/cli/utility.rb +46 -107
  9. data/lib/backup/compressor/base.rb +14 -2
  10. data/lib/backup/compressor/bzip2.rb +10 -24
  11. data/lib/backup/compressor/gzip.rb +10 -24
  12. data/lib/backup/compressor/lzma.rb +10 -23
  13. data/lib/backup/compressor/pbzip2.rb +12 -32
  14. data/lib/backup/config.rb +171 -0
  15. data/lib/backup/configuration/compressor/base.rb +1 -2
  16. data/lib/backup/configuration/compressor/pbzip2.rb +4 -4
  17. data/lib/backup/configuration/database/base.rb +2 -1
  18. data/lib/backup/configuration/database/mongodb.rb +8 -0
  19. data/lib/backup/configuration/database/mysql.rb +4 -0
  20. data/lib/backup/configuration/database/postgresql.rb +4 -0
  21. data/lib/backup/configuration/database/redis.rb +4 -0
  22. data/lib/backup/configuration/database/riak.rb +5 -1
  23. data/lib/backup/configuration/encryptor/base.rb +1 -2
  24. data/lib/backup/configuration/encryptor/open_ssl.rb +1 -1
  25. data/lib/backup/configuration/helpers.rb +7 -2
  26. data/lib/backup/configuration/notifier/base.rb +4 -28
  27. data/lib/backup/configuration/storage/base.rb +1 -1
  28. data/lib/backup/configuration/storage/dropbox.rb +14 -4
  29. data/lib/backup/configuration/syncer/base.rb +10 -0
  30. data/lib/backup/configuration/syncer/rsync/base.rb +28 -0
  31. data/lib/backup/configuration/syncer/rsync/local.rb +11 -0
  32. data/lib/backup/configuration/syncer/rsync/pull.rb +11 -0
  33. data/lib/backup/configuration/syncer/rsync/push.rb +31 -0
  34. data/lib/backup/configuration/syncer/s3.rb +0 -4
  35. data/lib/backup/database/base.rb +25 -7
  36. data/lib/backup/database/mongodb.rb +112 -75
  37. data/lib/backup/database/mysql.rb +54 -29
  38. data/lib/backup/database/postgresql.rb +60 -42
  39. data/lib/backup/database/redis.rb +61 -39
  40. data/lib/backup/database/riak.rb +35 -11
  41. data/lib/backup/dependency.rb +4 -5
  42. data/lib/backup/encryptor/base.rb +13 -1
  43. data/lib/backup/encryptor/gpg.rb +39 -39
  44. data/lib/backup/encryptor/open_ssl.rb +28 -38
  45. data/lib/backup/logger.rb +20 -11
  46. data/lib/backup/model.rb +206 -163
  47. data/lib/backup/notifier/base.rb +27 -25
  48. data/lib/backup/notifier/campfire.rb +7 -13
  49. data/lib/backup/notifier/hipchat.rb +28 -28
  50. data/lib/backup/notifier/mail.rb +24 -26
  51. data/lib/backup/notifier/presently.rb +10 -18
  52. data/lib/backup/notifier/prowl.rb +9 -17
  53. data/lib/backup/notifier/twitter.rb +11 -18
  54. data/lib/backup/package.rb +47 -0
  55. data/lib/backup/packager.rb +81 -16
  56. data/lib/backup/splitter.rb +48 -35
  57. data/lib/backup/storage/base.rb +44 -172
  58. data/lib/backup/storage/cloudfiles.rb +31 -46
  59. data/lib/backup/storage/cycler.rb +117 -0
  60. data/lib/backup/storage/dropbox.rb +92 -76
  61. data/lib/backup/storage/ftp.rb +30 -40
  62. data/lib/backup/storage/local.rb +44 -45
  63. data/lib/backup/storage/ninefold.rb +55 -49
  64. data/lib/backup/storage/rsync.rb +49 -56
  65. data/lib/backup/storage/s3.rb +33 -44
  66. data/lib/backup/storage/scp.rb +21 -48
  67. data/lib/backup/storage/sftp.rb +26 -40
  68. data/lib/backup/syncer/base.rb +7 -0
  69. data/lib/backup/syncer/rsync/base.rb +78 -0
  70. data/lib/backup/syncer/rsync/local.rb +53 -0
  71. data/lib/backup/syncer/rsync/pull.rb +38 -0
  72. data/lib/backup/syncer/rsync/push.rb +113 -0
  73. data/lib/backup/syncer/s3.rb +42 -32
  74. data/lib/backup/version.rb +1 -1
  75. data/spec/archive_spec.rb +235 -69
  76. data/spec/cleaner_spec.rb +304 -0
  77. data/spec/cli/helpers_spec.rb +142 -1
  78. data/spec/cli/utility_spec.rb +338 -13
  79. data/spec/compressor/base_spec.rb +31 -0
  80. data/spec/compressor/bzip2_spec.rb +60 -35
  81. data/spec/compressor/gzip_spec.rb +60 -35
  82. data/spec/compressor/lzma_spec.rb +60 -35
  83. data/spec/compressor/pbzip2_spec.rb +98 -37
  84. data/spec/config_spec.rb +321 -0
  85. data/spec/configuration/base_spec.rb +4 -4
  86. data/spec/configuration/compressor/bzip2_spec.rb +1 -0
  87. data/spec/configuration/compressor/gzip_spec.rb +1 -0
  88. data/spec/configuration/compressor/lzma_spec.rb +1 -0
  89. data/spec/configuration/compressor/pbzip2_spec.rb +32 -0
  90. data/spec/configuration/database/base_spec.rb +2 -1
  91. data/spec/configuration/database/mongodb_spec.rb +26 -16
  92. data/spec/configuration/database/mysql_spec.rb +4 -0
  93. data/spec/configuration/database/postgresql_spec.rb +4 -0
  94. data/spec/configuration/database/redis_spec.rb +4 -0
  95. data/spec/configuration/database/riak_spec.rb +4 -0
  96. data/spec/configuration/encryptor/gpg_spec.rb +1 -0
  97. data/spec/configuration/encryptor/open_ssl_spec.rb +1 -0
  98. data/spec/configuration/notifier/base_spec.rb +32 -0
  99. data/spec/configuration/notifier/campfire_spec.rb +1 -0
  100. data/spec/configuration/notifier/hipchat_spec.rb +1 -0
  101. data/spec/configuration/notifier/mail_spec.rb +1 -0
  102. data/spec/configuration/notifier/presently_spec.rb +1 -0
  103. data/spec/configuration/notifier/prowl_spec.rb +1 -0
  104. data/spec/configuration/notifier/twitter_spec.rb +1 -0
  105. data/spec/configuration/storage/cloudfiles_spec.rb +1 -0
  106. data/spec/configuration/storage/dropbox_spec.rb +4 -3
  107. data/spec/configuration/storage/ftp_spec.rb +1 -0
  108. data/spec/configuration/storage/local_spec.rb +1 -0
  109. data/spec/configuration/storage/ninefold_spec.rb +1 -0
  110. data/spec/configuration/storage/rsync_spec.rb +3 -1
  111. data/spec/configuration/storage/s3_spec.rb +1 -0
  112. data/spec/configuration/storage/scp_spec.rb +1 -0
  113. data/spec/configuration/storage/sftp_spec.rb +1 -0
  114. data/spec/configuration/syncer/rsync/base_spec.rb +33 -0
  115. data/spec/configuration/syncer/rsync/local_spec.rb +10 -0
  116. data/spec/configuration/syncer/rsync/pull_spec.rb +10 -0
  117. data/spec/configuration/syncer/{rsync_spec.rb → rsync/push_spec.rb} +12 -15
  118. data/spec/configuration/syncer/s3_spec.rb +2 -3
  119. data/spec/database/base_spec.rb +35 -20
  120. data/spec/database/mongodb_spec.rb +298 -119
  121. data/spec/database/mysql_spec.rb +147 -72
  122. data/spec/database/postgresql_spec.rb +155 -100
  123. data/spec/database/redis_spec.rb +200 -97
  124. data/spec/database/riak_spec.rb +82 -24
  125. data/spec/dependency_spec.rb +49 -0
  126. data/spec/encryptor/base_spec.rb +30 -0
  127. data/spec/encryptor/gpg_spec.rb +105 -28
  128. data/spec/encryptor/open_ssl_spec.rb +85 -114
  129. data/spec/logger_spec.rb +74 -8
  130. data/spec/model_spec.rb +528 -220
  131. data/spec/notifier/base_spec.rb +89 -0
  132. data/spec/notifier/campfire_spec.rb +147 -119
  133. data/spec/notifier/hipchat_spec.rb +140 -145
  134. data/spec/notifier/mail_spec.rb +190 -248
  135. data/spec/notifier/presently_spec.rb +147 -282
  136. data/spec/notifier/prowl_spec.rb +79 -111
  137. data/spec/notifier/twitter_spec.rb +87 -106
  138. data/spec/package_spec.rb +61 -0
  139. data/spec/packager_spec.rb +154 -0
  140. data/spec/spec_helper.rb +36 -13
  141. data/spec/splitter_spec.rb +90 -41
  142. data/spec/storage/base_spec.rb +95 -239
  143. data/spec/storage/cloudfiles_spec.rb +185 -75
  144. data/spec/storage/cycler_spec.rb +239 -0
  145. data/spec/storage/dropbox_spec.rb +318 -87
  146. data/spec/storage/ftp_spec.rb +165 -152
  147. data/spec/storage/local_spec.rb +206 -54
  148. data/spec/storage/ninefold_spec.rb +264 -128
  149. data/spec/storage/rsync_spec.rb +244 -163
  150. data/spec/storage/s3_spec.rb +175 -64
  151. data/spec/storage/scp_spec.rb +156 -150
  152. data/spec/storage/sftp_spec.rb +153 -135
  153. data/spec/syncer/base_spec.rb +22 -0
  154. data/spec/syncer/rsync/base_spec.rb +118 -0
  155. data/spec/syncer/rsync/local_spec.rb +121 -0
  156. data/spec/syncer/rsync/pull_spec.rb +90 -0
  157. data/spec/syncer/rsync/push_spec.rb +327 -0
  158. data/spec/syncer/s3_spec.rb +180 -91
  159. data/templates/cli/utility/config +1 -1
  160. data/templates/cli/utility/database/mongodb +4 -0
  161. data/templates/cli/utility/database/mysql +3 -0
  162. data/templates/cli/utility/database/postgresql +3 -0
  163. data/templates/cli/utility/database/redis +3 -0
  164. data/templates/cli/utility/database/riak +3 -0
  165. data/templates/cli/utility/storage/dropbox +4 -1
  166. data/templates/cli/utility/syncer/rsync_local +12 -0
  167. data/templates/cli/utility/syncer/{rsync → rsync_pull} +2 -2
  168. data/templates/cli/utility/syncer/rsync_push +17 -0
  169. data/templates/storage/dropbox/authorization_url.erb +1 -1
  170. metadata +42 -17
  171. data/lib/backup/configuration/syncer/rsync.rb +0 -45
  172. data/lib/backup/finder.rb +0 -87
  173. data/lib/backup/storage/object.rb +0 -47
  174. data/lib/backup/syncer/rsync.rb +0 -152
  175. data/spec/backup_spec.rb +0 -11
  176. data/spec/finder_spec.rb +0 -91
  177. data/spec/storage/object_spec.rb +0 -74
  178. data/spec/syncer/rsync_spec.rb +0 -195
@@ -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