Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'develop'

  • Loading branch information...
commit bca9ab8b05cfaf65e78f069264ca78f5b4231799 2 parents e9ee30c + f3fc6dc
Michael van Rooijen meskyanichi authored

Showing 196 changed files with 7,202 additions and 5,315 deletions. Show diff stats Hide diff stats

  1. +42 45 Gemfile.lock
  2. +7 4 Guardfile
  3. +10 7 README.md
  4. +2 2 backup.gemspec
  5. +27 97 lib/backup.rb
  6. +14 6 lib/backup/archive.rb
  7. +52 49 lib/backup/cli/helpers.rb
  8. +9 1 lib/backup/cli/utility.rb
  9. +10 4 lib/backup/compressor/base.rb
  10. +22 26 lib/backup/compressor/bzip2.rb
  11. +53 0 lib/backup/compressor/custom.rb
  12. +22 23 lib/backup/compressor/gzip.rb
  13. +15 13 lib/backup/compressor/lzma.rb
  14. +20 17 lib/backup/compressor/pbzip2.rb
  15. +6 3 lib/backup/config.rb
  16. +33 0 lib/backup/configuration.rb
  17. +0 15 lib/backup/configuration/base.rb
  18. +0 9 lib/backup/configuration/compressor/base.rb
  19. +0 23 lib/backup/configuration/compressor/bzip2.rb
  20. +0 23 lib/backup/configuration/compressor/gzip.rb
  21. +0 23 lib/backup/configuration/compressor/lzma.rb
  22. +0 28 lib/backup/configuration/compressor/pbzip2.rb
  23. +0 19 lib/backup/configuration/database/base.rb
  24. +0 49 lib/backup/configuration/database/mongodb.rb
  25. +0 42 lib/backup/configuration/database/mysql.rb
  26. +0 41 lib/backup/configuration/database/postgresql.rb
  27. +0 39 lib/backup/configuration/database/redis.rb
  28. +0 29 lib/backup/configuration/database/riak.rb
  29. +0 9 lib/backup/configuration/encryptor/base.rb
  30. +0 17 lib/backup/configuration/encryptor/gpg.rb
  31. +0 32 lib/backup/configuration/encryptor/open_ssl.rb
  32. +114 28 lib/backup/configuration/helpers.rb
  33. +0 28 lib/backup/configuration/notifier/base.rb
  34. +0 25 lib/backup/configuration/notifier/campfire.rb
  35. +0 41 lib/backup/configuration/notifier/hipchat.rb
  36. +0 112 lib/backup/configuration/notifier/mail.rb
  37. +0 25 lib/backup/configuration/notifier/presently.rb
  38. +0 23 lib/backup/configuration/notifier/prowl.rb
  39. +0 21 lib/backup/configuration/notifier/twitter.rb
  40. +0 18 lib/backup/configuration/storage/base.rb
  41. +0 25 lib/backup/configuration/storage/cloudfiles.rb
  42. +0 58 lib/backup/configuration/storage/dropbox.rb
  43. +0 29 lib/backup/configuration/storage/ftp.rb
  44. +0 17 lib/backup/configuration/storage/local.rb
  45. +0 20 lib/backup/configuration/storage/ninefold.rb
  46. +0 29 lib/backup/configuration/storage/rsync.rb
  47. +0 25 lib/backup/configuration/storage/s3.rb
  48. +0 25 lib/backup/configuration/storage/scp.rb
  49. +0 25 lib/backup/configuration/storage/sftp.rb
  50. +24 0 lib/backup/configuration/store.rb
  51. +0 10 lib/backup/configuration/syncer/base.rb
  52. +0 23 lib/backup/configuration/syncer/cloud.rb
  53. +0 30 lib/backup/configuration/syncer/cloud_files.rb
  54. +0 28 lib/backup/configuration/syncer/rsync/base.rb
  55. +0 11 lib/backup/configuration/syncer/rsync/local.rb
  56. +0 11 lib/backup/configuration/syncer/rsync/pull.rb
  57. +0 31 lib/backup/configuration/syncer/rsync/push.rb
  58. +0 23 lib/backup/configuration/syncer/s3.rb
  59. +0 6 lib/backup/database/base.rb
  60. +27 11 lib/backup/database/mongodb.rb
  61. +19 14 lib/backup/database/mysql.rb
  62. +16 11 lib/backup/database/postgresql.rb
  63. +7 11 lib/backup/database/redis.rb
  64. +3 6 lib/backup/database/riak.rb
  65. +5 11 lib/backup/dependency.rb
  66. +14 5 lib/backup/model.rb
  67. +3 16 lib/backup/notifier/campfire.rb
  68. +1 7 lib/backup/notifier/hipchat.rb
  69. +1 1  lib/backup/notifier/mail.rb
  70. +0 88 lib/backup/notifier/presently.rb
  71. +29 19 lib/backup/packager.rb
  72. +110 0 lib/backup/pipeline.rb
  73. +4 7 lib/backup/storage/dropbox.rb
  74. +8 4 lib/backup/syncer/base.rb
  75. +0 187 lib/backup/syncer/cloud.rb
  76. +247 0 lib/backup/syncer/cloud/base.rb
  77. +78 0 lib/backup/syncer/cloud/cloud_files.rb
  78. +68 0 lib/backup/syncer/cloud/s3.rb
  79. +0 56 lib/backup/syncer/cloud_files.rb
  80. +1 4 lib/backup/syncer/rsync/base.rb
  81. +9 5 lib/backup/syncer/rsync/local.rb
  82. +1 1  lib/backup/syncer/rsync/pull.rb
  83. +10 5 lib/backup/syncer/rsync/push.rb
  84. +0 47 lib/backup/syncer/s3.rb
  85. +1 1  lib/backup/version.rb
  86. +6 0 spec-live/.gitignore
  87. +7 0 spec-live/README
  88. +153 0 spec-live/backups/config.rb
  89. +43 0 spec-live/backups/config.yml.template
  90. +30 0 spec-live/compressor/custom_spec.rb
  91. +30 0 spec-live/compressor/gzip_spec.rb
  92. +85 0 spec-live/notifier/mail_spec.rb
  93. +85 0 spec-live/spec_helper.rb
  94. +151 0 spec-live/storage/dropbox_spec.rb
  95. +83 0 spec-live/storage/local_spec.rb
  96. +193 0 spec-live/storage/scp_spec.rb
  97. +124 0 spec-live/syncer/cloud/s3_spec.rb
  98. +86 31 spec/archive_spec.rb
  99. +8 0 spec/cleaner_spec.rb
  100. +200 75 spec/cli/helpers_spec.rb
  101. +11 3 spec/cli/utility_spec.rb
  102. +31 10 spec/compressor/base_spec.rb
  103. +212 57 spec/compressor/bzip2_spec.rb
  104. +106 0 spec/compressor/custom_spec.rb
  105. +212 57 spec/compressor/gzip_spec.rb
  106. +75 35 spec/compressor/lzma_spec.rb
  107. +93 52 spec/compressor/pbzip2_spec.rb
  108. +0 35 spec/configuration/base_spec.rb
  109. +0 29 spec/configuration/compressor/bzip2_spec.rb
  110. +0 29 spec/configuration/compressor/gzip_spec.rb
  111. +0 29 spec/configuration/compressor/lzma_spec.rb
  112. +0 32 spec/configuration/compressor/pbzip2_spec.rb
  113. +0 17 spec/configuration/database/base_spec.rb
  114. +0 56 spec/configuration/database/mongodb_spec.rb
  115. +0 53 spec/configuration/database/mysql_spec.rb
  116. +0 53 spec/configuration/database/postgresql_spec.rb
  117. +0 50 spec/configuration/database/redis_spec.rb
  118. +0 35 spec/configuration/database/riak_spec.rb
  119. +0 26 spec/configuration/encryptor/gpg_spec.rb
  120. +0 35 spec/configuration/encryptor/open_ssl_spec.rb
  121. +406 0 spec/configuration/helpers_spec.rb
  122. +0 32 spec/configuration/notifier/base_spec.rb
  123. +0 32 spec/configuration/notifier/campfire_spec.rb
  124. +0 44 spec/configuration/notifier/hipchat_spec.rb
  125. +0 71 spec/configuration/notifier/mail_spec.rb
  126. +0 35 spec/configuration/notifier/presently_spec.rb
  127. +0 29 spec/configuration/notifier/prowl_spec.rb
  128. +0 35 spec/configuration/notifier/twitter_spec.rb
  129. +0 41 spec/configuration/storage/cloudfiles_spec.rb
  130. +0 38 spec/configuration/storage/dropbox_spec.rb
  131. +0 44 spec/configuration/storage/ftp_spec.rb
  132. +0 29 spec/configuration/storage/local_spec.rb
  133. +0 32 spec/configuration/storage/ninefold_spec.rb
  134. +0 41 spec/configuration/storage/rsync_spec.rb
  135. +0 38 spec/configuration/storage/s3_spec.rb
  136. +0 41 spec/configuration/storage/scp_spec.rb
  137. +0 41 spec/configuration/storage/sftp_spec.rb
  138. +39 0 spec/configuration/store_spec.rb
  139. +0 44 spec/configuration/syncer/cloud_files_spec.rb
  140. +0 33 spec/configuration/syncer/rsync/base_spec.rb
  141. +0 10 spec/configuration/syncer/rsync/local_spec.rb
  142. +0 10 spec/configuration/syncer/rsync/pull_spec.rb
  143. +0 43 spec/configuration/syncer/rsync/push_spec.rb
  144. +0 38 spec/configuration/syncer/s3_spec.rb
  145. +62 0 spec/configuration_spec.rb
  146. +19 10 spec/database/base_spec.rb
  147. +195 70 spec/database/mongodb_spec.rb
  148. +183 64 spec/database/mysql_spec.rb
  149. +167 53 spec/database/postgresql_spec.rb
  150. +121 46 spec/database/redis_spec.rb
  151. +96 27 spec/database/riak_spec.rb
  152. +2 0  spec/dependency_spec.rb
  153. +10 0 spec/encryptor/base_spec.rb
  154. +29 13 spec/encryptor/gpg_spec.rb
  155. +40 21 spec/encryptor/open_ssl_spec.rb
  156. +4 0 spec/logger_spec.rb
  157. +19 2 spec/model_spec.rb
  158. +32 17 spec/notifier/base_spec.rb
  159. +63 45 spec/notifier/campfire_spec.rb
  160. +79 56 spec/notifier/hipchat_spec.rb
  161. +82 46 spec/notifier/mail_spec.rb
  162. +0 181 spec/notifier/presently_spec.rb
  163. +53 32 spec/notifier/prowl_spec.rb
  164. +62 41 spec/notifier/twitter_spec.rb
  165. +95 36 spec/packager_spec.rb
  166. +259 0 spec/pipeline_spec.rb
  167. +6 5 spec/spec_helper.rb
  168. +61 41 spec/storage/base_spec.rb
  169. +69 45 spec/storage/cloudfiles_spec.rb
  170. +158 36 spec/storage/dropbox_spec.rb
  171. +69 45 spec/storage/ftp_spec.rb
  172. +47 23 spec/storage/local_spec.rb
  173. +55 31 spec/storage/ninefold_spec.rb
  174. +67 50 spec/storage/rsync_spec.rb
  175. +65 41 spec/storage/s3_spec.rb
  176. +65 41 spec/storage/scp_spec.rb
  177. +65 41 spec/storage/sftp_spec.rb
  178. +91 4 spec/syncer/base_spec.rb
  179. +511 0 spec/syncer/cloud/base_spec.rb
  180. +181 0 spec/syncer/cloud/cloud_files_spec.rb
  181. +174 0 spec/syncer/cloud/s3_spec.rb
  182. +0 192 spec/syncer/cloud_files_spec.rb
  183. +46 66 spec/syncer/rsync/base_spec.rb
  184. +55 26 spec/syncer/rsync/local_spec.rb
  185. +15 4 spec/syncer/rsync/pull_spec.rb
  186. +59 52 spec/syncer/rsync/push_spec.rb
  187. +0 192 spec/syncer/s3_spec.rb
  188. +1 4 templates/cli/utility/compressor/bzip2
  189. +11 0 templates/cli/utility/compressor/custom
  190. +1 4 templates/cli/utility/compressor/gzip
  191. +3 0  templates/cli/utility/compressor/lzma
  192. +3 0  templates/cli/utility/compressor/pbzip2
  193. +4 1 templates/cli/utility/database/mysql
  194. +0 13 templates/cli/utility/notifier/presently
  195. +17 19 templates/cli/utility/syncer/cloud_files
  196. +18 20 templates/cli/utility/syncer/s3
87 Gemfile.lock
@@ -2,29 +2,25 @@ PATH
2 2 remote: .
3 3 specs:
4 4 backup (3.0.23)
5   - POpen4 (~> 0.1.4)
  5 + open4 (~> 1.3.0)
6 6 thor (~> 0.14.6)
7 7
8 8 GEM
9 9 remote: http://rubygems.org/
10 10 specs:
11   - POpen4 (0.1.4)
12   - Platform (>= 0.4.0)
13   - open4
14   - Platform (0.4.0)
15   - activesupport (3.1.3)
  11 + activesupport (3.2.2)
  12 + i18n (~> 0.6)
16 13 multi_json (~> 1.0)
17   - addressable (2.2.6)
  14 + addressable (2.2.7)
18 15 builder (3.0.0)
19   - crack (0.1.8)
20 16 diff-lcs (1.1.3)
21   - dropbox-sdk (1.1)
  17 + dropbox-sdk (1.2)
22 18 json
23   - excon (0.9.4)
24   - faraday (0.7.5)
25   - addressable (~> 2.2.6)
26   - multipart-post (~> 1.1.3)
27   - rack (>= 1.1.0, < 2)
  19 + excon (0.9.6)
  20 + faraday (0.7.6)
  21 + addressable (~> 2.2)
  22 + multipart-post (~> 1.1)
  23 + rack (~> 1.1)
28 24 ffi (1.0.11)
29 25 fog (1.1.2)
30 26 builder
@@ -37,56 +33,58 @@ GEM
37 33 nokogiri (~> 1.5.0)
38 34 ruby-hmac
39 35 formatador (0.2.1)
40   - fuubar (0.0.6)
  36 + fuubar (1.0.0)
41 37 rspec (~> 2.0)
42   - rspec-instafail (~> 0.1.8)
  38 + rspec-instafail (~> 0.2.0)
43 39 ruby-progressbar (~> 0.0.10)
44 40 growl (1.0.3)
45   - guard (0.10.0)
  41 + guard (1.0.1)
46 42 ffi (>= 0.5.0)
47 43 thor (~> 0.14.6)
48 44 guard-rspec (0.6.0)
49 45 guard (>= 0.10.0)
50 46 hipchat (0.4.1)
51 47 httparty
52   - httparty (0.7.8)
53   - crack (= 0.1.8)
  48 + httparty (0.8.1)
  49 + multi_json
  50 + multi_xml
54 51 i18n (0.6.0)
55   - json (1.5.4)
56   - libnotify (0.7.1)
57   - mail (2.4.1)
  52 + json (1.6.5)
  53 + libnotify (0.7.2)
  54 + mail (2.4.4)
58 55 i18n (>= 0.4.0)
59 56 mime-types (~> 1.16)
60 57 treetop (~> 1.4.8)
61 58 metaclass (0.0.1)
62 59 mime-types (1.17.2)
63   - mocha (0.10.0)
  60 + mocha (0.10.5)
64 61 metaclass (~> 0.0.1)
65 62 multi_json (1.0.4)
66   - multipart-post (1.1.4)
  63 + multi_xml (0.4.2)
  64 + multipart-post (1.1.5)
67 65 net-scp (1.0.4)
68 66 net-ssh (>= 1.99.1)
69 67 net-sftp (2.0.5)
70 68 net-ssh (>= 2.0.9)
71   - net-ssh (2.1.4)
72   - nokogiri (1.5.0)
  69 + net-ssh (2.3.0)
  70 + nokogiri (1.5.2)
73 71 open4 (1.3.0)
74   - parallel (0.5.12)
  72 + parallel (0.5.16)
75 73 polyglot (0.3.3)
76 74 prowler (1.3.1)
77   - rack (1.4.0)
78   - rb-fsevent (0.4.3.1)
  75 + rack (1.4.1)
  76 + rb-fsevent (0.9.0)
79 77 rb-inotify (0.8.8)
80 78 ffi (>= 0.5.0)
81   - rspec (2.8.0)
82   - rspec-core (~> 2.8.0)
83   - rspec-expectations (~> 2.8.0)
84   - rspec-mocks (~> 2.8.0)
85   - rspec-core (2.8.0)
86   - rspec-expectations (2.8.0)
87   - diff-lcs (~> 1.1.2)
88   - rspec-instafail (0.1.9)
89   - rspec-mocks (2.8.0)
  79 + rspec (2.9.0)
  80 + rspec-core (~> 2.9.0)
  81 + rspec-expectations (~> 2.9.0)
  82 + rspec-mocks (~> 2.9.0)
  83 + rspec-core (2.9.0)
  84 + rspec-expectations (2.9.0)
  85 + diff-lcs (~> 1.1.3)
  86 + rspec-instafail (0.2.2)
  87 + rspec-mocks (2.9.0)
90 88 ruby-hmac (0.4.0)
91 89 ruby-progressbar (0.0.10)
92 90 simple_oauth (0.1.5)
@@ -95,7 +93,7 @@ GEM
95 93 treetop (1.4.10)
96 94 polyglot
97 95 polyglot (>= 0.3.1)
98   - twitter (2.0.2)
  96 + twitter (2.1.1)
99 97 activesupport (>= 2.3.9, < 4)
100 98 faraday (~> 0.7)
101 99 multi_json (~> 1.0)
@@ -106,21 +104,20 @@ PLATFORMS
106 104
107 105 DEPENDENCIES
108 106 backup!
109   - dropbox-sdk (~> 1.1.0)
110   - fog (>= 0.11.0)
  107 + dropbox-sdk (~> 1.2.0)
  108 + fog (~> 1.1.0)
111 109 fuubar
112 110 growl
113 111 guard
114 112 guard-rspec
115 113 hipchat (~> 0.4.1)
116   - httparty (~> 0.7.4)
117   - json (~> 1.5.1)
  114 + httparty (~> 0.8.1)
118 115 libnotify
119   - mail (>= 2.4.0)
  116 + mail (~> 2.4.0)
120 117 mocha
121 118 net-scp (~> 1.0.4)
122 119 net-sftp (~> 2.0.5)
123   - net-ssh (~> 2.1.4)
  120 + net-ssh (~> 2.3.0)
124 121 parallel (~> 0.5.12)
125 122 prowler (>= 1.3.1)
126 123 rb-fsevent
11 Guardfile
@@ -12,10 +12,13 @@
12 12 guard "rspec",
13 13 :version => 2,
14 14 :rvm => ["1.9.3", "1.9.2", "1.8.7"],
15   - :bundler => true,
16   - :cli => "--color --format Fuubar" do
  15 + :cli => "--color --format Fuubar",
  16 + :notification => false,
  17 + :all_after_pass => false,
  18 + :all_on_start => false do
17 19
  20 + watch("lib/backup.rb") { "spec" }
  21 + watch("spec/spec_helper.rb") { "spec" }
  22 + watch(%r{^lib/backup/(.+)\.rb}) {|m| "spec/#{ m[1] }_spec.rb" }
18 23 watch(%r{^spec/.+_spec\.rb})
19   - watch(%r{^lib/(.+)\.rb}) { "spec" }
20   - watch("spec/spec_helper.rb") { "spec" }
21 24 end
17 README.md
Source Rendered
@@ -69,6 +69,9 @@ Below you find a list of components that Backup currently supports. If you'd lik
69 69 - Dropbox Web Service
70 70 - Remote Servers *(Only Protocols: FTP, SFTP, SCP)*
71 71 - Local Storage
  72 +
  73 +[Cycling Wiki Page](https://github.com/meskyanichi/backup/wiki/Cycling)
  74 +
72 75 - **Backup Splitting, applies to:**
73 76 - Amazon Simple Storage Service (S3)
74 77 - Rackspace Cloud Files (Mosso)
@@ -76,13 +79,12 @@ Below you find a list of components that Backup currently supports. If you'd lik
76 79 - Dropbox Web Service
77 80 - Remote Servers *(Only Protocols: FTP, SFTP, SCP)*
78 81 - Local Storage
79   -- **Incremental Backups, applies to:**
80   - - Remote Servers *(Only Protocols: RSync)*
81   -
82   -[Cycling Wiki Page](https://github.com/meskyanichi/backup/wiki/Cycling)
83 82
84 83 [Splitter Wiki Page](https://github.com/meskyanichi/backup/wiki/Splitter)
85 84
  85 +- **Incremental Backups, applies to:**
  86 + - Remote Servers *(Only Protocols: RSync)*
  87 +
86 88 ### Syncers
87 89
88 90 - RSync (Push, Pull and Local)
@@ -128,7 +130,8 @@ Below you find a list of components that Backup currently supports. If you'd lik
128 130 A sample Backup configuration file
129 131 ----------------------------------
130 132
131   -This is a Backup configuration file. Check it out and read the explanation below. Backup has a [great wiki](https://github.com/meskyanichi/backup/wiki) which explains each component of Backup in detail.
  133 +This is a Backup configuration file. Check it out and read the explanation below.
  134 +Backup has a [great wiki](https://github.com/meskyanichi/backup/wiki) which explains each component of Backup in detail.
132 135
133 136 ``` rb
134 137 Backup::Model.new(:sample_backup, 'A sample backup configuration') do
@@ -193,7 +196,7 @@ Backup::Model.new(:sample_backup, 'A sample backup configuration') do
193 196 s3.keep = 20
194 197 end
195 198
196   - sync_with S3 do |s3|
  199 + sync_with Cloud::S3 do |s3|
197 200 s3.access_key_id = "my_access_key_id"
198 201 s3.secret_access_key = "my_secret_access_key"
199 202 s3.bucket = "my-bucket"
@@ -252,7 +255,7 @@ of `-aa`, `-ab` and `-ac`. These files will then be individually transfered. Thi
252 255 Amazon S3, Rackspace Cloud Files, or other 3rd party storage services which limit you to "5GB per file" uploads. So with
253 256 this, the backup file size is no longer a constraint.
254 257
255   -Additionally we have also defined a **S3 Syncer** ( `sync_with S3` ), which does not follow the above process of
  258 +Additionally we have also defined a **S3 Syncer** ( `sync_with Cloud::S3` ), which does not follow the above process of
256 259 archiving/compression/encryption, but instead will directly sync the whole `videos` and `music` folder structures from
257 260 your machine to your Amazon S3 account. (very efficient and cost-effective since it will only transfer files that were
258 261 added/changed. Additionally, since we flagged it to 'mirror', it'll also remove files from S3 that no longer exist). If
4 backup.gemspec
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
26 26
27 27 ##
28 28 # Gem dependencies
29   - gem.add_dependency 'thor', ['~> 0.14.6']
30   - gem.add_dependency 'POpen4', ['~> 0.1.4']
  29 + gem.add_dependency 'thor', ['~> 0.14.6']
  30 + gem.add_dependency 'open4', ['~> 1.3.0']
31 31
32 32 end
124 lib/backup.rb
@@ -7,17 +7,8 @@
7 7 require 'yaml'
8 8 require 'etc'
9 9
10   -# Attempt load to POpen4 and Thor Libraries
11   -begin
12   - gem 'POpen4', '~> 0.1.4'
13   - gem 'thor', '~> 0.14.6'
14   - require 'popen4'
15   - require 'thor'
16   -rescue LoadError
17   - puts "\nBackup requires Thor to load the CLI Utility (Command Line Interface Utility) and POpen4 to determine the status of the unix processes."
18   - puts "Please install both the Thor and POpen4 libraries first:\n\ngem install thor -v '~> 0.14.6'\ngem install POpen4 -v '~> 0.1.4'"
19   - exit 1
20   -end
  10 +require 'open4'
  11 +require 'thor'
21 12
22 13 ##
23 14 # The Backup Ruby Gem
@@ -33,26 +24,9 @@ module Backup
33 24 ENCRYPTOR_PATH = File.join(LIBRARY_PATH, 'encryptor')
34 25 NOTIFIER_PATH = File.join(LIBRARY_PATH, 'notifier')
35 26 SYNCER_PATH = File.join(LIBRARY_PATH, 'syncer')
36   - CONFIGURATION_PATH = File.join(LIBRARY_PATH, 'configuration')
37 27 TEMPLATE_PATH = File.expand_path('../../templates', __FILE__)
38 28
39 29 ##
40   - # Autoload Backup base files
41   - autoload :Model, File.join(LIBRARY_PATH, 'model')
42   - autoload :Archive, File.join(LIBRARY_PATH, 'archive')
43   - autoload :Packager, File.join(LIBRARY_PATH, 'packager')
44   - autoload :Package, File.join(LIBRARY_PATH, 'package')
45   - autoload :Cleaner, File.join(LIBRARY_PATH, 'cleaner')
46   - autoload :Splitter, File.join(LIBRARY_PATH, 'splitter')
47   - autoload :Config, File.join(LIBRARY_PATH, 'config')
48   - autoload :Binder, File.join(LIBRARY_PATH, 'binder')
49   - autoload :Template, File.join(LIBRARY_PATH, 'template')
50   - autoload :Dependency, File.join(LIBRARY_PATH, 'dependency')
51   - autoload :Logger, File.join(LIBRARY_PATH, 'logger')
52   - autoload :Version, File.join(LIBRARY_PATH, 'version')
53   - autoload :Errors, File.join(LIBRARY_PATH, 'errors')
54   -
55   - ##
56 30 # Autoload Backup CLI files
57 31 module CLI
58 32 autoload :Helpers, File.join(CLI_PATH, 'helpers')
@@ -78,10 +52,12 @@ module Storage
78 52 ##
79 53 # Autoload Backup syncer files
80 54 module Syncer
81   - autoload :Base, File.join(SYNCER_PATH, 'base')
82   - autoload :Cloud, File.join(SYNCER_PATH, 'cloud')
83   - autoload :CloudFiles, File.join(SYNCER_PATH, 'cloud_files')
84   - autoload :S3, File.join(SYNCER_PATH, 's3')
  55 + autoload :Base, File.join(SYNCER_PATH, 'base')
  56 + module Cloud
  57 + autoload :Base, File.join(SYNCER_PATH, 'cloud', 'base')
  58 + autoload :CloudFiles, File.join(SYNCER_PATH, 'cloud', 'cloud_files')
  59 + autoload :S3, File.join(SYNCER_PATH, 'cloud', 's3')
  60 + end
85 61 module RSync
86 62 autoload :Base, File.join(SYNCER_PATH, 'rsync', 'base')
87 63 autoload :Local, File.join(SYNCER_PATH, 'rsync', 'local')
@@ -107,6 +83,7 @@ module Compressor
107 83 autoload :Base, File.join(COMPRESSOR_PATH, 'base')
108 84 autoload :Gzip, File.join(COMPRESSOR_PATH, 'gzip')
109 85 autoload :Bzip2, File.join(COMPRESSOR_PATH, 'bzip2')
  86 + autoload :Custom, File.join(COMPRESSOR_PATH, 'custom')
110 87 autoload :Pbzip2, File.join(COMPRESSOR_PATH, 'pbzip2')
111 88 autoload :Lzma, File.join(COMPRESSOR_PATH, 'lzma')
112 89 end
@@ -127,75 +104,28 @@ module Notifier
127 104 autoload :Mail, File.join(NOTIFIER_PATH, 'mail')
128 105 autoload :Twitter, File.join(NOTIFIER_PATH, 'twitter')
129 106 autoload :Campfire, File.join(NOTIFIER_PATH, 'campfire')
130   - autoload :Presently, File.join(NOTIFIER_PATH, 'presently')
131 107 autoload :Prowl, File.join(NOTIFIER_PATH, 'prowl')
132 108 autoload :Hipchat, File.join(NOTIFIER_PATH, 'hipchat')
133 109 end
134 110
135 111 ##
136   - # Autoload Backup configuration files
137   - module Configuration
138   - autoload :Base, File.join(CONFIGURATION_PATH, 'base')
139   - autoload :Helpers, File.join(CONFIGURATION_PATH, 'helpers')
140   -
141   - module Notifier
142   - autoload :Base, File.join(CONFIGURATION_PATH, 'notifier', 'base')
143   - autoload :Mail, File.join(CONFIGURATION_PATH, 'notifier', 'mail')
144   - autoload :Twitter, File.join(CONFIGURATION_PATH, 'notifier', 'twitter')
145   - autoload :Campfire, File.join(CONFIGURATION_PATH, 'notifier', 'campfire')
146   - autoload :Presently, File.join(CONFIGURATION_PATH, 'notifier', 'presently')
147   - autoload :Prowl, File.join(CONFIGURATION_PATH, 'notifier', 'prowl')
148   - autoload :Hipchat, File.join(CONFIGURATION_PATH, 'notifier', 'hipchat')
149   - end
150   -
151   - module Encryptor
152   - autoload :Base, File.join(CONFIGURATION_PATH, 'encryptor', 'base')
153   - autoload :OpenSSL, File.join(CONFIGURATION_PATH, 'encryptor', 'open_ssl')
154   - autoload :GPG, File.join(CONFIGURATION_PATH, 'encryptor', 'gpg')
155   - end
156   -
157   - module Compressor
158   - autoload :Base, File.join(CONFIGURATION_PATH, 'compressor', 'base')
159   - autoload :Gzip, File.join(CONFIGURATION_PATH, 'compressor', 'gzip')
160   - autoload :Bzip2, File.join(CONFIGURATION_PATH, 'compressor', 'bzip2')
161   - autoload :Pbzip2, File.join(CONFIGURATION_PATH, 'compressor', 'pbzip2')
162   - autoload :Lzma, File.join(CONFIGURATION_PATH, 'compressor', 'lzma')
163   - end
164   -
165   - module Storage
166   - autoload :Base, File.join(CONFIGURATION_PATH, 'storage', 'base')
167   - autoload :S3, File.join(CONFIGURATION_PATH, 'storage', 's3')
168   - autoload :CloudFiles, File.join(CONFIGURATION_PATH, 'storage', 'cloudfiles')
169   - autoload :Ninefold, File.join(CONFIGURATION_PATH, 'storage', 'ninefold')
170   - autoload :Dropbox, File.join(CONFIGURATION_PATH, 'storage', 'dropbox')
171   - autoload :FTP, File.join(CONFIGURATION_PATH, 'storage', 'ftp')
172   - autoload :SFTP, File.join(CONFIGURATION_PATH, 'storage', 'sftp')
173   - autoload :SCP, File.join(CONFIGURATION_PATH, 'storage', 'scp')
174   - autoload :RSync, File.join(CONFIGURATION_PATH, 'storage', 'rsync')
175   - autoload :Local, File.join(CONFIGURATION_PATH, 'storage', 'local')
176   - end
177   -
178   - module Syncer
179   - autoload :Base, File.join(CONFIGURATION_PATH, 'syncer', 'base')
180   - autoload :Cloud, File.join(CONFIGURATION_PATH, 'syncer', 'cloud')
181   - autoload :CloudFiles, File.join(CONFIGURATION_PATH, 'syncer', 'cloud_files')
182   - autoload :S3, File.join(CONFIGURATION_PATH, 'syncer', 's3')
183   - module RSync
184   - autoload :Base, File.join(CONFIGURATION_PATH, 'syncer', 'rsync', 'base')
185   - autoload :Local, File.join(CONFIGURATION_PATH, 'syncer', 'rsync', 'local')
186   - autoload :Push, File.join(CONFIGURATION_PATH, 'syncer', 'rsync', 'push')
187   - autoload :Pull, File.join(CONFIGURATION_PATH, 'syncer', 'rsync', 'pull')
188   - end
189   - end
190   -
191   - module Database
192   - autoload :Base, File.join(CONFIGURATION_PATH, 'database', 'base')
193   - autoload :MySQL, File.join(CONFIGURATION_PATH, 'database', 'mysql')
194   - autoload :PostgreSQL, File.join(CONFIGURATION_PATH, 'database', 'postgresql')
195   - autoload :MongoDB, File.join(CONFIGURATION_PATH, 'database', 'mongodb')
196   - autoload :Redis, File.join(CONFIGURATION_PATH, 'database', 'redis')
197   - autoload :Riak, File.join(CONFIGURATION_PATH, 'database', 'riak')
198   - end
199   - end
  112 + # Require Backup base files
  113 + %w{
  114 + archive
  115 + binder
  116 + cleaner
  117 + config
  118 + configuration
  119 + dependency
  120 + errors
  121 + logger
  122 + model
  123 + package
  124 + packager
  125 + pipeline
  126 + splitter
  127 + template
  128 + version
  129 + }.each {|lib| require File.join(LIBRARY_PATH, lib) }
200 130
201 131 end
20 lib/backup/archive.rb
@@ -67,26 +67,34 @@ def tar_options(options)
67 67 # will be piped through the Compressor command and the file extension
68 68 # will be adjusted to indicate the type of compression used.
69 69 def perform!
70   - Logger.message "#{ self.class } started packaging and archiving:\n" +
  70 + Logger.message "#{ self.class } has started archiving:\n" +
71 71 paths.map {|path| " #{path}" }.join("\n")
72 72
73 73 archive_path = File.join(Config.tmp_path, @model.trigger, 'archives')
74 74 FileUtils.mkdir_p(archive_path)
75 75
76 76 archive_ext = 'tar'
77   - archive_cmd = "#{ utility(:tar) } #{ tar_args } -cf - " +
  77 + pipeline = Pipeline.new
  78 +
  79 + pipeline << "#{ utility(:tar) } #{ tar_args } -cPf - " +
78 80 "#{ paths_to_exclude } #{ paths_to_package }"
79 81
80 82 if @model.compressor
81 83 @model.compressor.compress_with do |command, ext|
82   - archive_cmd << " | #{command}"
  84 + pipeline << command
83 85 archive_ext << ext
84 86 end
85 87 end
86 88
87   - archive_cmd << " > '#{ File.join(archive_path, "#{name}.#{archive_ext}") }'"
88   -
89   - run(archive_cmd)
  89 + pipeline << "cat > '#{ File.join(archive_path, "#{name}.#{archive_ext}") }'"
  90 + pipeline.run
  91 + if pipeline.success?
  92 + Logger.message "#{ self.class } Complete!"
  93 + else
  94 + raise Errors::Archive::PipelineError,
  95 + "Failed to Create Backup Archive\n" +
  96 + pipeline.error_messages
  97 + end
90 98 end
91 99
92 100 private
101 lib/backup/cli/helpers.rb
@@ -6,45 +6,73 @@ module Helpers
6 6 UTILITY = {}
7 7
8 8 ##
9   - # Runs a given command in an isolated (sub) process using POpen4.
10   - # The STDOUT, STDERR and the returned exit code of the utility will be stored in the process_data Hash.
  9 + # Runs a system command
11 10 #
12   - # If a command returns an exit code other than 0, an exception will raise and the backup process will abort.
13   - # Some utilities return exit codes other than 0 which aren't an issue in Backup's context. If this is the case,
14   - # you can pass in an array of exit codes to ignore (whitelist), for example:
  11 + # All messages generated by the command will be logged.
  12 + # Messages on STDERR will be logged as warnings.
15 13 #
16   - # run("tar -cf /output.tar /some/folder", :ignore_exit_codes => [1])
  14 + # If the command fails to execute, or returns a non-zero exit status
  15 + # an Error will be raised.
17 16 #
18   - # So if the `tar` utility returns in this case 1, Backup will consider it an acceptable return code.
19   - #
20   - # Note: Exit code 0 is always automatically added to the :ignore_exit_codes array, regardless of whether you specify an
21   - # array to ignore or not.
22   - def run(command, options = {})
23   - command.gsub!(/^\s+/, "")
  17 + # Returns nil
  18 + def run(command)
  19 + name = command_name(command)
  20 + Logger.message "Running system utility '#{ name }'..."
  21 +
  22 + begin
  23 + out, err = '', ''
  24 + ps = Open4.popen4(command) do |pid, stdin, stdout, stderr|
  25 + stdin.close
  26 + out, err = stdout.read.strip, stderr.read.strip
  27 + end
  28 + rescue Exception => e
  29 + raise Errors::CLI::SystemCallError.wrap(e, <<-EOS)
  30 + Failed to execute system command on #{ RUBY_PLATFORM }
  31 + Command was: #{ command }
  32 + EOS
  33 + end
  34 +
  35 + if ps.success?
  36 + unless out.empty?
  37 + Logger.message(
  38 + out.lines.map {|line| "#{ name }:STDOUT: #{ line }" }.join
  39 + )
  40 + end
24 41
25   - process_data = Hash.new
26   - pid, stdin, stdout, stderr = Open4::popen4(command)
27   - ignored, process_data[:status] = Process::waitpid2(pid)
28   - process_data[:stdout] = stdout.read
29   - process_data[:stderr] = stderr.read
30   - process_data[:ignore_exit_codes] = ((options[:ignore_exit_codes] || Array.new) << 0).uniq
  42 + unless err.empty?
  43 + Logger.warn(
  44 + err.lines.map {|line| "#{ name }:STDERR: #{ line }" }.join
  45 + )
  46 + end
31 47
32   - raise_if_command_failed!(command_name(command), process_data)
33   - process_data[:stdout]
  48 + return nil
  49 + else
  50 + raise Errors::CLI::SystemCallError, <<-EOS
  51 + '#{ name }' Failed on #{ RUBY_PLATFORM }
  52 + The following information should help to determine the problem:
  53 + Command was: #{ command }
  54 + Exit Status: #{ ps.exitstatus }
  55 + STDOUT Messages: #{ out.empty? ? 'None' : "\n#{ out }" }
  56 + STDERR Messages: #{ err.empty? ? 'None' : "\n#{ err }" }
  57 + EOS
  58 + end
34 59 end
35 60
  61 +
36 62 ##
37 63 # Returns the full path to the specified utility.
38 64 # Raises an error if utility can not be found in the system's $PATH
39 65 def utility(name)
40   - path = UTILITY[name] || %x[which #{name} 2>/dev/null].chomp
  66 + name = name.to_s.strip
  67 + raise Errors::CLI::UtilityNotFoundError,
  68 + 'Utility Name Empty' if name.empty?
  69 +
  70 + path = UTILITY[name] || %x[which #{ name } 2>/dev/null].chomp
41 71 if path.empty?
42 72 raise Errors::CLI::UtilityNotFoundError, <<-EOS
43   - Path to '#{ name }' could not be found.
  73 + Could not locate '#{ name }'.
44 74 Make sure the specified utility is installed
45 75 and available in your system's $PATH.
46   - If this is a database utility, you may need to specify the full path
47   - using the Database's '<utility_name>_utility' configuration setting.
48 76 EOS
49 77 end
50 78 UTILITY[name] = path
@@ -58,31 +86,6 @@ def command_name(command)
58 86 command.split('/')[-1]
59 87 end
60 88
61   - ##
62   - # Inspects the exit code returned from the POpen4 child process. If the exit code isn't listed
63   - # in the process_data[:ignore_exit_codes] array, an exception will be raised, aborting the backup process.
64   - #
65   - # Information regarding the error ( EXIT CODE and STDERR ) will be returned to the shell so the user can
66   - # investigate the issue.
67   - #
68   - # raises Backup::Errors::CLI::SystemCallError
69   - def raise_if_command_failed!(utility, process_data)
70   - unless process_data[:ignore_exit_codes].include?(process_data[:status].to_i)
71   -
72   - stderr = process_data[:stderr].empty? ?
73   - nil : "STDERR:\n#{process_data[:stderr]}\n"
74   - stdout = process_data[:stdout].empty? ?
75   - nil : "STDOUT:\n#{process_data[:stdout]}\n"
76   -
77   - raise Errors::CLI::SystemCallError, <<-EOS
78   - Failed to run #{utility} on #{RUBY_PLATFORM}
79   - The following information should help to determine the problem:
80   - Exit Code: #{process_data[:status]}
81   - #{stderr}#{stdout}
82   - EOS
83   - end
84   - end
85   -
86 89 end
87 90 end
88 91 end
10 lib/backup/cli/utility.rb
@@ -187,9 +187,10 @@ def decrypt
187 187 ##
188 188 # [Dependencies]
189 189 # Returns a list of Backup's dependencies
190   - desc 'dependencies', 'Display the list of dependencies for Backup, or install them through Backup.'
  190 + desc 'dependencies', 'Display the list of dependencies for Backup, check the installation status, or install them through Backup.'
191 191 method_option :install, :type => :string
192 192 method_option :list, :type => :boolean
  193 + method_option :installed, :type => :string
193 194 def dependencies
194 195 unless options.any?
195 196 puts
@@ -198,6 +199,9 @@ def dependencies
198 199 puts
199 200 puts "To install one of these dependencies (with the correct version), run:\n\n"
200 201 puts " backup dependencies --install <name>"
  202 + puts
  203 + puts "To check if a dependency is already installed, run:\n\n"
  204 + puts " backup dependencies --installed <name>"
201 205 exit
202 206 end
203 207
@@ -220,6 +224,10 @@ def dependencies
220 224 puts "Please wait..\n\n"
221 225 puts %x[gem install #{options[:install]} -v '#{Backup::Dependency.all[options[:install]][:version]}']
222 226 end
  227 +
  228 + if options[:installed]
  229 + puts %x[gem list -i -v '#{Backup::Dependency.all[options[:installed]][:version]}' #{options[:installed]}]
  230 + end
223 231 end
224 232
225 233 ##
14 lib/backup/compressor/base.rb
@@ -6,14 +6,17 @@ class Base
6 6 include Backup::CLI::Helpers
7 7 include Backup::Configuration::Helpers
8 8
9   - def initialize
10   - load_defaults!
  9 + ##
  10 + # Yields to the block the compressor command and filename extension.
  11 + def compress_with
  12 + log!
  13 + yield @cmd, @ext
11 14 end
12 15
13 16 private
14 17
15 18 ##
16   - # Return the encryptor name, with Backup namespace removed
  19 + # Return the compressor name, with Backup namespace removed
17 20 def compressor_name
18 21 self.class.to_s.sub('Backup::', '')
19 22 end
@@ -22,8 +25,11 @@ def compressor_name
22 25 # Logs a message to the console and log file to inform
23 26 # the client that Backup is using the compressor
24 27 def log!
25   - Logger.message "Using #{ compressor_name } for compression."
  28 + Logger.message "Using #{ compressor_name } for compression.\n" +
  29 + " Command: '#{ @cmd }'\n" +
  30 + " Ext: '#{ @ext }'"
26 31 end
  32 +
27 33 end
28 34 end
29 35 end
48 lib/backup/compressor/bzip2.rb
@@ -5,44 +5,40 @@ module Compressor
5 5 class Bzip2 < Base
6 6
7 7 ##
8   - # Tells Backup::Compressor::Bzip2 to compress
9   - # better (-9) rather than faster when set to true
10   - attr_accessor :best
  8 + # Specify the level of compression to use.
  9 + #
  10 + # Values should be a single digit from 1 to 9.
  11 + # Note that setting the level to either extreme may or may not
  12 + # give the desired result. Be sure to check the documentation
  13 + # for the compressor being used.
  14 + #
  15 + # The default `level` is 9.
  16 + attr_accessor :level
  17 +
  18 + attr_deprecate :fast, :version => '3.0.24',
  19 + :replacement => :level,
  20 + :value => lambda {|val| val ? 1 : nil }
  21 + attr_deprecate :best, :version => '3.0.24',
  22 + :replacement => :level,
  23 + :value => lambda {|val| val ? 9 : nil }
11 24
12 25 ##
13   - # Tells Backup::Compressor::Bzip2 to compress
14   - # faster (-1) rather than better when set to true
15   - attr_accessor :fast
16   -
17   - ##
18   - # Creates a new instance of Backup::Compressor::Bzip2 and
19   - # configures it to either compress faster or better
20   - # bzip2 compresses by default with -9 (best compression)
21   - # and lower block sizes don't make things significantly faster
22   - # (according to official bzip2 docs)
  26 + # Creates a new instance of Backup::Compressor::Bzip2
23 27 def initialize(&block)
24   - super
  28 + load_defaults!
25 29
26   - @best ||= false
27   - @fast ||= false
  30 + @level ||= false
28 31
29 32 instance_eval(&block) if block_given?
30   - end
31 33
32   - ##
33   - # Yields to the block the compressor command with options
34   - # and it's filename extension.
35   - def compress_with
36   - log!
37   - yield "#{ utility(:bzip2) }#{ options }", '.bz2'
  34 + @cmd = "#{ utility(:bzip2) }#{ options }"
  35 + @ext = '.bz2'
38 36 end
39 37
40 38 private
41 39
42   - ##
43   - # Returns the option syntax for compressing
44 40 def options
45   - " #{ '--best ' if @best }#{ '--fast' if @fast }".rstrip
  41 + " -#{ @level }" if @level
46 42 end
47 43
48 44 end
53 lib/backup/compressor/custom.rb
... ... @@ -0,0 +1,53 @@
  1 +# encoding: utf-8
  2 +
  3 +module Backup
  4 + module Compressor
  5 + class Custom < Base
  6 +
  7 + ##
  8 + # Specify the system command to invoke a compressor,
  9 + # including any command-line arguments.
  10 + # e.g. @compressor.command = 'pbzip2 -p2 -4'
  11 + #
  12 + # The data to be compressed will be piped to the command's STDIN,
  13 + # and it should write the compressed data to STDOUT.
  14 + # i.e. `cat file.tar | %command% > file.tar.%extension%`
  15 + attr_accessor :command
  16 +
  17 + ##
  18 + # File extension to append to the compressed file's filename.
  19 + # e.g. @compressor.extension = '.bz2'
  20 + attr_accessor :extension
  21 +
  22 + ##
  23 + # Initializes a new custom compressor.
  24 + def initialize(&block)
  25 + load_defaults!
  26 +
  27 + instance_eval(&block) if block_given?
  28 +
  29 + @cmd = set_cmd
  30 + @ext = set_ext
  31 + end
  32 +
  33 + private
  34 +
  35 + ##
  36 + # Return the command line using the full path.
  37 + # Ensures the command exists and is executable.
  38 + def set_cmd
  39 + parts = @command.to_s.split(' ')
  40 + parts[0] = utility(parts[0])
  41 + parts.join(' ')
  42 + end
  43 +
  44 + ##
  45 + # Return the extension given without whitespace.
  46 + # If extension was not set, return an empty string
  47 + def set_ext
  48 + @extension.to_s.strip
  49 + end
  50 +
  51 + end
  52 + end
  53 +end
45 lib/backup/compressor/gzip.rb
@@ -5,41 +5,40 @@ module Compressor
5 5 class Gzip < Base
6 6
7 7 ##
8   - # Tells Backup::Compressor::Gzip to compress
9   - # better rather than faster when set to true
10   - attr_accessor :best
  8 + # Specify the level of compression to use.
  9 + #
  10 + # Values should be a single digit from 1 to 9.
  11 + # Note that setting the level to either extreme may or may not
  12 + # give the desired result. Be sure to check the documentation
  13 + # for the compressor being used.
  14 + #
  15 + # The default `level` is 6.
  16 + attr_accessor :level
  17 +
  18 + attr_deprecate :fast, :version => '3.0.24',
  19 + :replacement => :level,
  20 + :value => lambda {|val| val ? 1 : nil }
  21 + attr_deprecate :best, :version => '3.0.24',
  22 + :replacement => :level,
  23 + :value => lambda {|val| val ? 9 : nil }
11 24
12 25 ##
13   - # Tells Backup::Compressor::Gzip to compress
14   - # faster rather than better when set to true
15   - attr_accessor :fast
16   -
17   - ##
18   - # Creates a new instance of Backup::Compressor::Gzip and
19   - # configures it to either compress faster or better
  26 + # Creates a new instance of Backup::Compressor::Gzip
20 27 def initialize(&block)
21   - super
  28 + load_defaults!
22 29
23   - @best ||= false
24   - @fast ||= false
  30 + @level ||= false
25 31
26 32 instance_eval(&block) if block_given?
27   - end
28 33
29   - ##
30   - # Yields to the block the compressor command with options
31   - # and it's filename extension.
32   - def compress_with
33   - log!
34   - yield "#{ utility(:gzip) }#{ options }", '.gz'
  34 + @cmd = "#{ utility(:gzip) }#{ options }"
  35 + @ext = '.gz'
35 36 end
36 37
37 38 private
38 39
39   - ##
40   - # Returns the gzip option syntax for compressing
41 40 def options
42   - " #{ '--best ' if @best }#{ '--fast' if @fast }".rstrip
  41 + " -#{ @level }" if @level
43 42 end
44 43
45 44 end
28 lib/backup/compressor/lzma.rb
@@ -15,34 +15,36 @@ class Lzma < Base
15 15 attr_accessor :fast
16 16
17 17 ##
18   - # Creates a new instance of Backup::Compressor::Lzma and
19   - # configures it to either compress faster or better
20   - # Lzma compresses by default with -9 (best compression)
21   - # and lower block sizes don't make things significantly faster
22   - # (according to official bzip2 docs)
  18 + # Creates a new instance of Backup::Compressor::Lzma
23 19 def initialize(&block)
24   - super
  20 + load_defaults!
25 21
26 22 @best ||= false
27 23 @fast ||= false
28 24
29 25 instance_eval(&block) if block_given?
  26 +
  27 + @cmd = "#{ utility(:lzma) }#{ options }"
  28 + @ext = '.lzma'
30 29 end
31 30
  31 +
32 32 ##
33   - # Yields to the block the compressor command with options
34   - # and it's filename extension.
  33 + # Yields to the block the compressor command and filename extension.
35 34 def compress_with
36   - log!
37   - yield "#{ utility(:lzma) }#{ options }", '.lzma'
  35 + Backup::Logger.warn(
  36 + "[DEPRECATION WARNING]\n" +
  37 + " Compressor::Lzma is being deprecated as of backup v.3.0.24\n" +
  38 + " and will soon be removed. Please see the Compressors wiki page at\n" +
  39 + " https://github.com/meskyanichi/backup/wiki/Compressors"
  40 + )
  41 + super
38 42 end
39 43
40 44 private
41 45
42   - ##
43   - # Returns the option syntax for compressing
44 46 def options
45   - " #{ '--best ' if @best }#{ '--fast' if @fast }".rstrip
  47 + (' --best' if @best) || (' --fast' if @fast)
46 48 end
47 49
48 50 end
37 lib/backup/compressor/pbzip2.rb
@@ -5,50 +5,53 @@ module Compressor
5 5 class Pbzip2 < Base
6 6
7 7 ##
8   - # Tells Backup::Compressor::Pbzip2 to compress
  8 + # Tells Backup::Compressor::Lzma to compress
9 9 # better (-9) rather than faster when set to true
10 10 attr_accessor :best
11 11
12 12 ##
13   - # Tells Backup::Compressor::Pbzip2 to compress
  13 + # Tells Backup::Compressor::Lzma to compress
14 14 # faster (-1) rather than better when set to true
15 15 attr_accessor :fast
16 16
17 17 ##
18   - # Tells Backup::Compressor::Pbzip2 how many processors
19   - # use, by default autodetect is used
  18 + # Tells Backup::Compressor::Pbzip2 how many processors to use.
  19 + # Autodetects the number of active CPUs by default.
20 20 attr_accessor :processors
21 21
22 22 ##
23   - # Creates a new instance of Backup::Compressor::Pbzip2 and
24   - # configures it to either compress faster or better
25   - # bzip2 compresses by default with -9 (best compression)
26   - # and lower block sizes don't make things significantly faster
27   - # (according to official bzip2 docs)
  23 + # Creates a new instance of Backup::Compressor::Pbzip2
28 24 def initialize(&block)
29   - super
  25 + load_defaults!
30 26
31 27 @best ||= false
32 28 @fast ||= false
33 29 @processors ||= false
34 30
35 31 instance_eval(&block) if block_given?
  32 +
  33 + @cmd = "#{ utility(:pbzip2) }#{ options }"
  34 + @ext = '.bz2'
36 35 end
37 36
38 37 ##
39   - # Yields to the block the compressor command with options
40   - # and it's filename extension.
  38 + # Yields to the block the compressor command and filename extension.
41 39 def compress_with
42   - log!
43   - yield "#{ utility(:pbzip2) }#{ options }", '.bz2'
  40 + Backup::Logger.warn(
  41 + "[DEPRECATION WARNING]\n" +
  42 + " Compressor::Pbzip2 is being deprecated as of backup v.3.0.24\n" +
  43 + " and will soon be removed. Please see the Compressors wiki page at\n" +
  44 + " https://github.com/meskyanichi/backup/wiki/Compressors"
  45 + )
  46 + super
44 47 end
45 48
46 49 private
47 50
48   - ##
49   - # Returns the gzip option syntax for compressing
50 51 def options
51   - " #{ '--best ' if @best }#{ '--fast ' if @fast }#{ "-p#{@processors}" if @processors }".rstrip
  52 + level = (' --best' if @best) || (' --fast' if @fast)
  53 + cpus = " -p#{ @processors }" if @processors
  54 + "#{ level }#{ cpus }"
52 55 end
53 56
54 57 end
9 lib/backup/config.rb
@@ -107,13 +107,16 @@ def add_dsl_constants!
107 107 ['S3', 'CloudFiles', 'Ninefold', 'Dropbox', 'FTP',
108 108 'SFTP', 'SCP', 'RSync', 'Local'],
109 109 # Compressors
110   - ['Gzip', 'Bzip2', 'Pbzip2', 'Lzma'],
  110 + ['Gzip', 'Bzip2', 'Custom', 'Pbzip2', 'Lzma'],
111 111 # Encryptors
112 112 ['OpenSSL', 'GPG'],
113 113 # Syncers
114   - ['Rackspace', 'S3', { 'RSync' => ['Push', 'Pull', 'Local'] }],
  114 + [
  115 + { 'Cloud' => ['CloudFiles', 'S3'] },
  116 + { 'RSync' => ['Push', 'Pull', 'Local'] }
  117 + ],
115 118 # Notifiers
116   - ['Mail', 'Twitter', 'Campfire', 'Presently', 'Prowl', 'Hipchat']
  119 + ['Mail', 'Twitter', 'Campfire', 'Prowl', 'Hipchat']
117 120 ]
118 121 )
119 122 end
33 lib/backup/configuration.rb
... ... @@ -0,0 +1,33 @@
  1 +# encoding: utf-8
  2 +
  3 +%w[helpers store].each do |file|
  4 + require File.expand_path("../configuration/#{file}", __FILE__)
  5 +end
  6 +
  7 +# Temporary measure for deprecating the use of Configuration
  8 +# namespaced classes for setting pre-configured defaults.
  9 +module Backup
  10 + module Configuration
  11 + extend self
  12 +
  13 + ##
  14 + # Pass calls on to the proper class and log a warning
  15 + def defaults(&block)
  16 + klass = eval(self.to_s.sub('Configuration::', ''))
  17 + Logger.warn Errors::ConfigurationError.new <<-EOS
  18 + [DEPRECATION WARNING]
  19 + #{ self }.defaults is being deprecated.
  20 + To set pre-configured defaults for #{ klass }, use:
  21 + #{ klass }.defaults
  22 + EOS
  23 + klass.defaults(&block)
  24 + end
  25 +
  26 + private
  27 +
  28 + def const_missing(const)
  29 + const_set(const, Module.new { extend Configuration })
  30 + end
  31 +
  32 + end
  33 +end
15 lib/backup/configuration/base.rb
... ... @@ -1,15 +0,0 @@
1   -# encoding: utf-8
2   -
3   -module Backup
4   - module Configuration
5   - class Base
6   - extend Backup::Configuration::Helpers
7   -
8   - ##
9   - # Allows for global configuration through block-notation
10   - def self.defaults