backup_checksum 3.0.23

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.
Files changed (244) hide show
  1. data/.gitignore +7 -0
  2. data/.travis.yml +10 -0
  3. data/Gemfile +28 -0
  4. data/Gemfile.lock +130 -0
  5. data/Guardfile +21 -0
  6. data/LICENSE.md +24 -0
  7. data/README.md +476 -0
  8. data/backup_checksum.gemspec +32 -0
  9. data/bin/backup +11 -0
  10. data/lib/backup.rb +217 -0
  11. data/lib/backup/archive.rb +117 -0
  12. data/lib/backup/binder.rb +22 -0
  13. data/lib/backup/checksum/base.rb +44 -0
  14. data/lib/backup/checksum/shasum.rb +16 -0
  15. data/lib/backup/cleaner.rb +121 -0
  16. data/lib/backup/cli/helpers.rb +88 -0
  17. data/lib/backup/cli/utility.rb +247 -0
  18. data/lib/backup/compressor/base.rb +29 -0
  19. data/lib/backup/compressor/bzip2.rb +50 -0
  20. data/lib/backup/compressor/gzip.rb +47 -0
  21. data/lib/backup/compressor/lzma.rb +50 -0
  22. data/lib/backup/compressor/pbzip2.rb +56 -0
  23. data/lib/backup/config.rb +173 -0
  24. data/lib/backup/configuration/base.rb +15 -0
  25. data/lib/backup/configuration/checksum/base.rb +9 -0
  26. data/lib/backup/configuration/checksum/shasum.rb +9 -0
  27. data/lib/backup/configuration/compressor/base.rb +9 -0
  28. data/lib/backup/configuration/compressor/bzip2.rb +23 -0
  29. data/lib/backup/configuration/compressor/gzip.rb +23 -0
  30. data/lib/backup/configuration/compressor/lzma.rb +23 -0
  31. data/lib/backup/configuration/compressor/pbzip2.rb +28 -0
  32. data/lib/backup/configuration/database/base.rb +19 -0
  33. data/lib/backup/configuration/database/mongodb.rb +49 -0
  34. data/lib/backup/configuration/database/mysql.rb +42 -0
  35. data/lib/backup/configuration/database/postgresql.rb +41 -0
  36. data/lib/backup/configuration/database/redis.rb +39 -0
  37. data/lib/backup/configuration/database/riak.rb +29 -0
  38. data/lib/backup/configuration/encryptor/base.rb +9 -0
  39. data/lib/backup/configuration/encryptor/gpg.rb +17 -0
  40. data/lib/backup/configuration/encryptor/open_ssl.rb +32 -0
  41. data/lib/backup/configuration/helpers.rb +52 -0
  42. data/lib/backup/configuration/notifier/base.rb +28 -0
  43. data/lib/backup/configuration/notifier/campfire.rb +25 -0
  44. data/lib/backup/configuration/notifier/hipchat.rb +41 -0
  45. data/lib/backup/configuration/notifier/mail.rb +112 -0
  46. data/lib/backup/configuration/notifier/presently.rb +25 -0
  47. data/lib/backup/configuration/notifier/prowl.rb +23 -0
  48. data/lib/backup/configuration/notifier/twitter.rb +21 -0
  49. data/lib/backup/configuration/storage/base.rb +18 -0
  50. data/lib/backup/configuration/storage/cloudfiles.rb +25 -0
  51. data/lib/backup/configuration/storage/dropbox.rb +58 -0
  52. data/lib/backup/configuration/storage/ftp.rb +29 -0
  53. data/lib/backup/configuration/storage/local.rb +17 -0
  54. data/lib/backup/configuration/storage/ninefold.rb +20 -0
  55. data/lib/backup/configuration/storage/rsync.rb +29 -0
  56. data/lib/backup/configuration/storage/s3.rb +25 -0
  57. data/lib/backup/configuration/storage/scp.rb +25 -0
  58. data/lib/backup/configuration/storage/sftp.rb +25 -0
  59. data/lib/backup/configuration/syncer/base.rb +10 -0
  60. data/lib/backup/configuration/syncer/cloud.rb +23 -0
  61. data/lib/backup/configuration/syncer/cloud_files.rb +30 -0
  62. data/lib/backup/configuration/syncer/rsync/base.rb +28 -0
  63. data/lib/backup/configuration/syncer/rsync/local.rb +11 -0
  64. data/lib/backup/configuration/syncer/rsync/pull.rb +11 -0
  65. data/lib/backup/configuration/syncer/rsync/push.rb +31 -0
  66. data/lib/backup/configuration/syncer/s3.rb +23 -0
  67. data/lib/backup/database/base.rb +59 -0
  68. data/lib/backup/database/mongodb.rb +232 -0
  69. data/lib/backup/database/mysql.rb +163 -0
  70. data/lib/backup/database/postgresql.rb +146 -0
  71. data/lib/backup/database/redis.rb +139 -0
  72. data/lib/backup/database/riak.rb +69 -0
  73. data/lib/backup/dependency.rb +114 -0
  74. data/lib/backup/encryptor/base.rb +29 -0
  75. data/lib/backup/encryptor/gpg.rb +80 -0
  76. data/lib/backup/encryptor/open_ssl.rb +72 -0
  77. data/lib/backup/errors.rb +124 -0
  78. data/lib/backup/logger.rb +152 -0
  79. data/lib/backup/model.rb +386 -0
  80. data/lib/backup/notifier/base.rb +81 -0
  81. data/lib/backup/notifier/campfire.rb +168 -0
  82. data/lib/backup/notifier/hipchat.rb +99 -0
  83. data/lib/backup/notifier/mail.rb +206 -0
  84. data/lib/backup/notifier/presently.rb +88 -0
  85. data/lib/backup/notifier/prowl.rb +65 -0
  86. data/lib/backup/notifier/twitter.rb +70 -0
  87. data/lib/backup/package.rb +51 -0
  88. data/lib/backup/packager.rb +108 -0
  89. data/lib/backup/pipeline.rb +107 -0
  90. data/lib/backup/splitter.rb +75 -0
  91. data/lib/backup/storage/base.rb +119 -0
  92. data/lib/backup/storage/cloudfiles.rb +87 -0
  93. data/lib/backup/storage/cycler.rb +117 -0
  94. data/lib/backup/storage/dropbox.rb +181 -0
  95. data/lib/backup/storage/ftp.rb +119 -0
  96. data/lib/backup/storage/local.rb +82 -0
  97. data/lib/backup/storage/ninefold.rb +116 -0
  98. data/lib/backup/storage/rsync.rb +149 -0
  99. data/lib/backup/storage/s3.rb +94 -0
  100. data/lib/backup/storage/scp.rb +99 -0
  101. data/lib/backup/storage/sftp.rb +108 -0
  102. data/lib/backup/syncer/base.rb +42 -0
  103. data/lib/backup/syncer/cloud.rb +190 -0
  104. data/lib/backup/syncer/cloud_files.rb +56 -0
  105. data/lib/backup/syncer/rsync/base.rb +52 -0
  106. data/lib/backup/syncer/rsync/local.rb +53 -0
  107. data/lib/backup/syncer/rsync/pull.rb +38 -0
  108. data/lib/backup/syncer/rsync/push.rb +113 -0
  109. data/lib/backup/syncer/s3.rb +47 -0
  110. data/lib/backup/template.rb +46 -0
  111. data/lib/backup/version.rb +43 -0
  112. data/spec/archive_spec.rb +335 -0
  113. data/spec/cleaner_spec.rb +304 -0
  114. data/spec/cli/helpers_spec.rb +176 -0
  115. data/spec/cli/utility_spec.rb +363 -0
  116. data/spec/compressor/base_spec.rb +31 -0
  117. data/spec/compressor/bzip2_spec.rb +83 -0
  118. data/spec/compressor/gzip_spec.rb +83 -0
  119. data/spec/compressor/lzma_spec.rb +83 -0
  120. data/spec/compressor/pbzip2_spec.rb +124 -0
  121. data/spec/config_spec.rb +321 -0
  122. data/spec/configuration/base_spec.rb +35 -0
  123. data/spec/configuration/compressor/bzip2_spec.rb +29 -0
  124. data/spec/configuration/compressor/gzip_spec.rb +29 -0
  125. data/spec/configuration/compressor/lzma_spec.rb +29 -0
  126. data/spec/configuration/compressor/pbzip2_spec.rb +32 -0
  127. data/spec/configuration/database/base_spec.rb +17 -0
  128. data/spec/configuration/database/mongodb_spec.rb +56 -0
  129. data/spec/configuration/database/mysql_spec.rb +53 -0
  130. data/spec/configuration/database/postgresql_spec.rb +53 -0
  131. data/spec/configuration/database/redis_spec.rb +50 -0
  132. data/spec/configuration/database/riak_spec.rb +35 -0
  133. data/spec/configuration/encryptor/gpg_spec.rb +26 -0
  134. data/spec/configuration/encryptor/open_ssl_spec.rb +35 -0
  135. data/spec/configuration/notifier/base_spec.rb +32 -0
  136. data/spec/configuration/notifier/campfire_spec.rb +32 -0
  137. data/spec/configuration/notifier/hipchat_spec.rb +44 -0
  138. data/spec/configuration/notifier/mail_spec.rb +71 -0
  139. data/spec/configuration/notifier/presently_spec.rb +35 -0
  140. data/spec/configuration/notifier/prowl_spec.rb +29 -0
  141. data/spec/configuration/notifier/twitter_spec.rb +35 -0
  142. data/spec/configuration/storage/cloudfiles_spec.rb +41 -0
  143. data/spec/configuration/storage/dropbox_spec.rb +38 -0
  144. data/spec/configuration/storage/ftp_spec.rb +44 -0
  145. data/spec/configuration/storage/local_spec.rb +29 -0
  146. data/spec/configuration/storage/ninefold_spec.rb +32 -0
  147. data/spec/configuration/storage/rsync_spec.rb +41 -0
  148. data/spec/configuration/storage/s3_spec.rb +38 -0
  149. data/spec/configuration/storage/scp_spec.rb +41 -0
  150. data/spec/configuration/storage/sftp_spec.rb +41 -0
  151. data/spec/configuration/syncer/cloud_files_spec.rb +44 -0
  152. data/spec/configuration/syncer/rsync/base_spec.rb +33 -0
  153. data/spec/configuration/syncer/rsync/local_spec.rb +10 -0
  154. data/spec/configuration/syncer/rsync/pull_spec.rb +10 -0
  155. data/spec/configuration/syncer/rsync/push_spec.rb +43 -0
  156. data/spec/configuration/syncer/s3_spec.rb +38 -0
  157. data/spec/database/base_spec.rb +54 -0
  158. data/spec/database/mongodb_spec.rb +428 -0
  159. data/spec/database/mysql_spec.rb +335 -0
  160. data/spec/database/postgresql_spec.rb +278 -0
  161. data/spec/database/redis_spec.rb +260 -0
  162. data/spec/database/riak_spec.rb +108 -0
  163. data/spec/dependency_spec.rb +49 -0
  164. data/spec/encryptor/base_spec.rb +30 -0
  165. data/spec/encryptor/gpg_spec.rb +134 -0
  166. data/spec/encryptor/open_ssl_spec.rb +129 -0
  167. data/spec/errors_spec.rb +306 -0
  168. data/spec/logger_spec.rb +363 -0
  169. data/spec/model_spec.rb +649 -0
  170. data/spec/notifier/base_spec.rb +89 -0
  171. data/spec/notifier/campfire_spec.rb +199 -0
  172. data/spec/notifier/hipchat_spec.rb +188 -0
  173. data/spec/notifier/mail_spec.rb +280 -0
  174. data/spec/notifier/presently_spec.rb +181 -0
  175. data/spec/notifier/prowl_spec.rb +117 -0
  176. data/spec/notifier/twitter_spec.rb +132 -0
  177. data/spec/package_spec.rb +61 -0
  178. data/spec/packager_spec.rb +225 -0
  179. data/spec/pipeline_spec.rb +257 -0
  180. data/spec/spec_helper.rb +59 -0
  181. data/spec/splitter_spec.rb +120 -0
  182. data/spec/storage/base_spec.rb +160 -0
  183. data/spec/storage/cloudfiles_spec.rb +230 -0
  184. data/spec/storage/cycler_spec.rb +239 -0
  185. data/spec/storage/dropbox_spec.rb +370 -0
  186. data/spec/storage/ftp_spec.rb +247 -0
  187. data/spec/storage/local_spec.rb +235 -0
  188. data/spec/storage/ninefold_spec.rb +319 -0
  189. data/spec/storage/rsync_spec.rb +345 -0
  190. data/spec/storage/s3_spec.rb +221 -0
  191. data/spec/storage/scp_spec.rb +209 -0
  192. data/spec/storage/sftp_spec.rb +220 -0
  193. data/spec/syncer/base_spec.rb +22 -0
  194. data/spec/syncer/cloud_files_spec.rb +192 -0
  195. data/spec/syncer/rsync/base_spec.rb +118 -0
  196. data/spec/syncer/rsync/local_spec.rb +121 -0
  197. data/spec/syncer/rsync/pull_spec.rb +90 -0
  198. data/spec/syncer/rsync/push_spec.rb +327 -0
  199. data/spec/syncer/s3_spec.rb +192 -0
  200. data/spec/version_spec.rb +21 -0
  201. data/templates/cli/utility/archive +25 -0
  202. data/templates/cli/utility/compressor/bzip2 +7 -0
  203. data/templates/cli/utility/compressor/gzip +7 -0
  204. data/templates/cli/utility/compressor/lzma +7 -0
  205. data/templates/cli/utility/compressor/pbzip2 +7 -0
  206. data/templates/cli/utility/config +31 -0
  207. data/templates/cli/utility/database/mongodb +18 -0
  208. data/templates/cli/utility/database/mysql +21 -0
  209. data/templates/cli/utility/database/postgresql +17 -0
  210. data/templates/cli/utility/database/redis +16 -0
  211. data/templates/cli/utility/database/riak +11 -0
  212. data/templates/cli/utility/encryptor/gpg +12 -0
  213. data/templates/cli/utility/encryptor/openssl +9 -0
  214. data/templates/cli/utility/model.erb +23 -0
  215. data/templates/cli/utility/notifier/campfire +12 -0
  216. data/templates/cli/utility/notifier/hipchat +15 -0
  217. data/templates/cli/utility/notifier/mail +22 -0
  218. data/templates/cli/utility/notifier/presently +13 -0
  219. data/templates/cli/utility/notifier/prowl +11 -0
  220. data/templates/cli/utility/notifier/twitter +13 -0
  221. data/templates/cli/utility/splitter +7 -0
  222. data/templates/cli/utility/storage/cloud_files +22 -0
  223. data/templates/cli/utility/storage/dropbox +20 -0
  224. data/templates/cli/utility/storage/ftp +12 -0
  225. data/templates/cli/utility/storage/local +7 -0
  226. data/templates/cli/utility/storage/ninefold +9 -0
  227. data/templates/cli/utility/storage/rsync +11 -0
  228. data/templates/cli/utility/storage/s3 +19 -0
  229. data/templates/cli/utility/storage/scp +11 -0
  230. data/templates/cli/utility/storage/sftp +11 -0
  231. data/templates/cli/utility/syncer/cloud_files +48 -0
  232. data/templates/cli/utility/syncer/rsync_local +12 -0
  233. data/templates/cli/utility/syncer/rsync_pull +17 -0
  234. data/templates/cli/utility/syncer/rsync_push +17 -0
  235. data/templates/cli/utility/syncer/s3 +45 -0
  236. data/templates/general/links +11 -0
  237. data/templates/general/version.erb +2 -0
  238. data/templates/notifier/mail/failure.erb +9 -0
  239. data/templates/notifier/mail/success.erb +7 -0
  240. data/templates/notifier/mail/warning.erb +9 -0
  241. data/templates/storage/dropbox/authorization_url.erb +6 -0
  242. data/templates/storage/dropbox/authorized.erb +4 -0
  243. data/templates/storage/dropbox/cache_file_written.erb +10 -0
  244. metadata +311 -0
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Storage::Local do
6
+ before do
7
+ Backup::Configuration::Storage::Local.defaults do |local|
8
+ local.path = 'my_backups'
9
+ local.keep = 20
10
+ end
11
+ end
12
+ after { Backup::Configuration::Storage::Local.clear_defaults! }
13
+
14
+ it 'should set the default local configuration' do
15
+ local = Backup::Configuration::Storage::Local
16
+ local.path.should == 'my_backups'
17
+ local.keep.should == 20
18
+ end
19
+
20
+ describe '#clear_defaults!' do
21
+ it 'should clear all the defaults, resetting them to nil' do
22
+ Backup::Configuration::Storage::Local.clear_defaults!
23
+
24
+ local = Backup::Configuration::Storage::Local
25
+ local.path.should == nil
26
+ local.keep.should == nil
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Storage::Ninefold do
6
+ before do
7
+ Backup::Configuration::Storage::Ninefold.defaults do |nf|
8
+ nf.storage_token = 'my_storage_token'
9
+ nf.storage_secret = 'my_storage_secret'
10
+ nf.path = 'my_backups'
11
+ end
12
+ end
13
+ after { Backup::Configuration::Storage::Ninefold.clear_defaults! }
14
+
15
+ it 'should set the default Ninefold configuration' do
16
+ ninefold = Backup::Configuration::Storage::Ninefold
17
+ ninefold.storage_token.should == 'my_storage_token'
18
+ ninefold.storage_secret.should == 'my_storage_secret'
19
+ ninefold.path.should == 'my_backups'
20
+ end
21
+
22
+ describe '#clear_defaults!' do
23
+ it 'should clear all the defaults, resetting them to nil' do
24
+ Backup::Configuration::Storage::Ninefold.clear_defaults!
25
+
26
+ ninefold = Backup::Configuration::Storage::Ninefold
27
+ ninefold.storage_token.should == nil
28
+ ninefold.storage_secret.should == nil
29
+ ninefold.path.should == nil
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Storage::RSync do
6
+ before do
7
+ Backup::Configuration::Storage::RSync.defaults do |rsync|
8
+ rsync.username = 'my_username'
9
+ rsync.password = 'my_password'
10
+ rsync.ip = '123.45.678.90'
11
+ rsync.port = 21
12
+ rsync.path = 'my_backups'
13
+ rsync.local = true
14
+ end
15
+ end
16
+ after { Backup::Configuration::Storage::RSync.clear_defaults! }
17
+
18
+ it 'should set the default rsync configuration' do
19
+ rsync = Backup::Configuration::Storage::RSync
20
+ rsync.username.should == 'my_username'
21
+ rsync.password.should == 'my_password'
22
+ rsync.ip.should == '123.45.678.90'
23
+ rsync.port.should == 21
24
+ rsync.path.should == 'my_backups'
25
+ rsync.local.should == true
26
+ end
27
+
28
+ describe '#clear_defaults!' do
29
+ it 'should clear all the defaults, resetting them to nil' do
30
+ Backup::Configuration::Storage::RSync.clear_defaults!
31
+
32
+ rsync = Backup::Configuration::Storage::RSync
33
+ rsync.username.should == nil
34
+ rsync.password.should == nil
35
+ rsync.ip.should == nil
36
+ rsync.port.should == nil
37
+ rsync.path.should == nil
38
+ rsync.local.should == nil
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Storage::S3 do
6
+ before do
7
+ Backup::Configuration::Storage::S3.defaults do |s3|
8
+ s3.access_key_id = 'my_access_key_id'
9
+ s3.secret_access_key = 'my_secret_access_key'
10
+ s3.region = 'us-east-1'
11
+ s3.bucket = 'my-bucket'
12
+ s3.path = 'my_backups'
13
+ end
14
+ end
15
+ after { Backup::Configuration::Storage::S3.clear_defaults! }
16
+
17
+ it 'should set the default S3 configuration' do
18
+ s3 = Backup::Configuration::Storage::S3
19
+ s3.access_key_id.should == 'my_access_key_id'
20
+ s3.secret_access_key.should == 'my_secret_access_key'
21
+ s3.region.should == 'us-east-1'
22
+ s3.bucket.should == 'my-bucket'
23
+ s3.path.should == 'my_backups'
24
+ end
25
+
26
+ describe '#clear_defaults!' do
27
+ it 'should clear all the defaults, resetting them to nil' do
28
+ Backup::Configuration::Storage::S3.clear_defaults!
29
+
30
+ s3 = Backup::Configuration::Storage::S3
31
+ s3.access_key_id.should == nil
32
+ s3.secret_access_key.should == nil
33
+ s3.region.should == nil
34
+ s3.bucket.should == nil
35
+ s3.path.should == nil
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Storage::SCP do
6
+ before do
7
+ Backup::Configuration::Storage::SCP.defaults do |scp|
8
+ scp.username = 'my_username'
9
+ scp.password = 'my_password'
10
+ scp.ip = '123.45.678.90'
11
+ scp.port = 21
12
+ scp.path = 'my_backups'
13
+ scp.keep = 20
14
+ end
15
+ end
16
+ after { Backup::Configuration::Storage::SCP.clear_defaults! }
17
+
18
+ it 'should set the default scp configuration' do
19
+ scp = Backup::Configuration::Storage::SCP
20
+ scp.username.should == 'my_username'
21
+ scp.password.should == 'my_password'
22
+ scp.ip.should == '123.45.678.90'
23
+ scp.port.should == 21
24
+ scp.path.should == 'my_backups'
25
+ scp.keep.should == 20
26
+ end
27
+
28
+ describe '#clear_defaults!' do
29
+ it 'should clear all the defaults, resetting them to nil' do
30
+ Backup::Configuration::Storage::SCP.clear_defaults!
31
+
32
+ scp = Backup::Configuration::Storage::SCP
33
+ scp.username.should == nil
34
+ scp.password.should == nil
35
+ scp.ip.should == nil
36
+ scp.port.should == nil
37
+ scp.path.should == nil
38
+ scp.keep.should == nil
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Storage::SFTP do
6
+ before do
7
+ Backup::Configuration::Storage::SFTP.defaults do |sftp|
8
+ sftp.username = 'my_username'
9
+ sftp.password = 'my_password'
10
+ sftp.ip = '123.45.678.90'
11
+ sftp.port = 22
12
+ sftp.path = 'my_backups'
13
+ sftp.keep = 20
14
+ end
15
+ end
16
+ after { Backup::Configuration::Storage::SFTP.clear_defaults! }
17
+
18
+ it 'should set the default sftp configuration' do
19
+ sftp = Backup::Configuration::Storage::SFTP
20
+ sftp.username.should == 'my_username'
21
+ sftp.password.should == 'my_password'
22
+ sftp.ip.should == '123.45.678.90'
23
+ sftp.port.should == 22
24
+ sftp.path.should == 'my_backups'
25
+ sftp.keep.should == 20
26
+ end
27
+
28
+ describe '#clear_defaults!' do
29
+ it 'should clear all the defaults, resetting them to nil' do
30
+ Backup::Configuration::Storage::SFTP.clear_defaults!
31
+
32
+ sftp = Backup::Configuration::Storage::SFTP
33
+ sftp.username.should == nil
34
+ sftp.password.should == nil
35
+ sftp.ip.should == nil
36
+ sftp.port.should == nil
37
+ sftp.path.should == nil
38
+ sftp.keep.should == nil
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Syncer::CloudFiles do
6
+ before do
7
+ Backup::Configuration::Syncer::CloudFiles.defaults do |cf|
8
+ cf.username = 'my-username'
9
+ cf.api_key = 'my-api-key'
10
+ cf.container = 'my-container'
11
+ cf.auth_url = 'my-auth-url'
12
+ cf.servicenet = true
13
+ cf.path = '/backups/'
14
+ cf.mirror = true
15
+ end
16
+ end
17
+ after { Backup::Configuration::Syncer::CloudFiles.clear_defaults! }
18
+
19
+ it 'should set the default cloud files configuration' do
20
+ cf = Backup::Configuration::Syncer::CloudFiles
21
+ cf.username.should == 'my-username'
22
+ cf.api_key.should == 'my-api-key'
23
+ cf.container.should == 'my-container'
24
+ cf.auth_url.should == 'my-auth-url'
25
+ cf.servicenet.should == true
26
+ cf.path.should == '/backups/'
27
+ cf.mirror.should == true
28
+ end
29
+
30
+ describe '#clear_defaults!' do
31
+ it 'should clear all the defaults, resetting them to nil' do
32
+ Backup::Configuration::Syncer::CloudFiles.clear_defaults!
33
+
34
+ cf = Backup::Configuration::Syncer::CloudFiles
35
+ cf.username.should == nil
36
+ cf.api_key.should == nil
37
+ cf.container.should == nil
38
+ cf.auth_url.should == nil
39
+ cf.servicenet.should == nil
40
+ cf.path.should == nil
41
+ cf.mirror.should == nil
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Syncer::RSync::Base do
6
+ before do
7
+ Backup::Configuration::Syncer::RSync::Base.defaults do |rsync|
8
+ #rsync.directories = 'cannot_have_a_default_value'
9
+ rsync.path = '~/backups/'
10
+ rsync.mirror = true
11
+ rsync.additional_options = []
12
+ end
13
+ end
14
+ after { Backup::Configuration::Syncer::RSync::Base.clear_defaults! }
15
+
16
+ it 'should set the default rsync configuration' do
17
+ rsync = Backup::Configuration::Syncer::RSync::Base
18
+ rsync.path.should == '~/backups/'
19
+ rsync.mirror.should == true
20
+ rsync.additional_options.should == []
21
+ end
22
+
23
+ describe '#clear_defaults!' do
24
+ it 'should clear all the defaults, resetting them to nil' do
25
+ Backup::Configuration::Syncer::RSync::Base.clear_defaults!
26
+
27
+ rsync = Backup::Configuration::Syncer::RSync::Base
28
+ rsync.path.should == nil
29
+ rsync.mirror.should == nil
30
+ rsync.additional_options.should == nil
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Syncer::RSync::Local do
6
+ it 'should be a subclass of RSync::Base' do
7
+ rsync = Backup::Configuration::Syncer::RSync::Local
8
+ rsync.superclass.should == Backup::Configuration::Syncer::RSync::Base
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Syncer::RSync::Pull do
6
+ it 'should be a subclass of RSync::Push' do
7
+ rsync = Backup::Configuration::Syncer::RSync::Pull
8
+ rsync.superclass.should == Backup::Configuration::Syncer::RSync::Push
9
+ end
10
+ end
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Syncer::RSync::Push do
6
+ before do
7
+ Backup::Configuration::Syncer::RSync::Push.defaults do |rsync|
8
+ rsync.username = 'my_username'
9
+ rsync.password = 'my_password'
10
+ rsync.ip = '123.45.678.90'
11
+ rsync.port = 22
12
+ rsync.compress = true
13
+ end
14
+ end
15
+ after { Backup::Configuration::Syncer::RSync::Push.clear_defaults! }
16
+
17
+ it 'should be a subclass of RSync::Base' do
18
+ rsync = Backup::Configuration::Syncer::RSync::Push
19
+ rsync.superclass.should == Backup::Configuration::Syncer::RSync::Base
20
+ end
21
+
22
+ it 'should set the default rsync configuration' do
23
+ rsync = Backup::Configuration::Syncer::RSync::Push
24
+ rsync.username.should == 'my_username'
25
+ rsync.password.should == 'my_password'
26
+ rsync.ip.should == '123.45.678.90'
27
+ rsync.port.should == 22
28
+ rsync.compress.should == true
29
+ end
30
+
31
+ describe '#clear_defaults!' do
32
+ it 'should clear all the defaults, resetting them to nil' do
33
+ Backup::Configuration::Syncer::RSync::Push.clear_defaults!
34
+
35
+ rsync = Backup::Configuration::Syncer::RSync::Push
36
+ rsync.username.should == nil
37
+ rsync.password.should == nil
38
+ rsync.ip.should == nil
39
+ rsync.port.should == nil
40
+ rsync.compress.should == nil
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Configuration::Syncer::S3 do
6
+ before do
7
+ Backup::Configuration::Syncer::S3.defaults do |s3|
8
+ s3.access_key_id = 'my_access_key_id'
9
+ s3.secret_access_key = 'my_secret_access_key'
10
+ s3.bucket = 'my-bucket'
11
+ s3.path = '/backups/'
12
+ s3.mirror = true
13
+ end
14
+ end
15
+ after { Backup::Configuration::Syncer::S3.clear_defaults! }
16
+
17
+ it 'should set the default s3 configuration' do
18
+ s3 = Backup::Configuration::Syncer::S3
19
+ s3.access_key_id.should == 'my_access_key_id'
20
+ s3.secret_access_key.should == 'my_secret_access_key'
21
+ s3.bucket.should == 'my-bucket'
22
+ s3.path.should == '/backups/'
23
+ s3.mirror.should == true
24
+ end
25
+
26
+ describe '#clear_defaults!' do
27
+ it 'should clear all the defaults, resetting them to nil' do
28
+ Backup::Configuration::Syncer::S3.clear_defaults!
29
+
30
+ s3 = Backup::Configuration::Syncer::S3
31
+ s3.access_key_id.should == nil
32
+ s3.secret_access_key.should == nil
33
+ s3.bucket.should == nil
34
+ s3.path.should == nil
35
+ s3.mirror.should == nil
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Database::Base do
6
+ let(:model) { Backup::Model.new('foo', 'foo') }
7
+ let(:db) { Backup::Database::Base.new(model) }
8
+
9
+ it 'should set #utility_path' do
10
+ db.utility_path.should be_nil
11
+ db.utility_path = 'utility path'
12
+ db.utility_path.should == 'utility path'
13
+ end
14
+
15
+ describe '#perform!' do
16
+ it 'should invoke prepare! and log!' do
17
+ s = sequence ''
18
+ db.expects(:prepare!).in_sequence(s)
19
+ db.expects(:log!).in_sequence(s)
20
+
21
+ db.perform!
22
+ end
23
+ end
24
+
25
+ context 'since CLI::Helpers are included' do
26
+ it 'should respond to the #utility method' do
27
+ db.respond_to?(:utility).should be_true
28
+ end
29
+ end
30
+
31
+ describe '#prepare!' do
32
+ it 'should set and create #dump_path' do
33
+ model = stub(:trigger => 'test_trigger')
34
+ db.instance_variable_set(:@model, model)
35
+ FileUtils.expects(:mkdir_p).with(
36
+ File.join(Backup::Config.tmp_path, 'test_trigger', 'databases', 'Base')
37
+ )
38
+ db.send(:prepare!)
39
+ db.instance_variable_get(:@dump_path).should ==
40
+ File.join(Backup::Config.tmp_path, 'test_trigger', 'databases', 'Base')
41
+ end
42
+ end
43
+
44
+ describe '#log!' do
45
+ it 'should use #database_name' do
46
+ db.stubs(:name).returns('database_name')
47
+ Backup::Logger.expects(:message).with(
48
+ "Database::Base started dumping and archiving 'database_name'."
49
+ )
50
+
51
+ db.send(:log!)
52
+ end
53
+ end
54
+ end