backup 3.0.19 → 3.0.20

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 (188) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +9 -8
  3. data/Gemfile.lock +19 -1
  4. data/Guardfile +13 -9
  5. data/README.md +93 -31
  6. data/backup.gemspec +3 -3
  7. data/bin/backup +6 -283
  8. data/lib/backup.rb +101 -72
  9. data/lib/backup/archive.rb +21 -9
  10. data/lib/backup/binder.rb +22 -0
  11. data/lib/backup/cleaner.rb +36 -0
  12. data/lib/backup/cli/helpers.rb +103 -0
  13. data/lib/backup/cli/utility.rb +308 -0
  14. data/lib/backup/compressor/base.rb +2 -2
  15. data/lib/backup/compressor/pbzip2.rb +76 -0
  16. data/lib/backup/configuration/compressor/pbzip2.rb +28 -0
  17. data/lib/backup/configuration/database/riak.rb +25 -0
  18. data/lib/backup/configuration/encryptor/open_ssl.rb +6 -0
  19. data/lib/backup/configuration/helpers.rb +5 -18
  20. data/lib/backup/configuration/notifier/base.rb +13 -0
  21. data/lib/backup/configuration/notifier/hipchat.rb +41 -0
  22. data/lib/backup/configuration/notifier/mail.rb +38 -0
  23. data/lib/backup/configuration/notifier/prowl.rb +23 -0
  24. data/lib/backup/configuration/storage/cloudfiles.rb +4 -0
  25. data/lib/backup/configuration/storage/dropbox.rb +8 -4
  26. data/lib/backup/database/base.rb +10 -2
  27. data/lib/backup/database/mongodb.rb +16 -19
  28. data/lib/backup/database/mysql.rb +2 -2
  29. data/lib/backup/database/postgresql.rb +2 -2
  30. data/lib/backup/database/redis.rb +15 -7
  31. data/lib/backup/database/riak.rb +45 -0
  32. data/lib/backup/dependency.rb +21 -7
  33. data/lib/backup/encryptor/base.rb +1 -1
  34. data/lib/backup/encryptor/open_ssl.rb +20 -5
  35. data/lib/backup/errors.rb +124 -0
  36. data/lib/backup/finder.rb +11 -3
  37. data/lib/backup/logger.rb +121 -82
  38. data/lib/backup/model.rb +103 -44
  39. data/lib/backup/notifier/base.rb +50 -0
  40. data/lib/backup/notifier/campfire.rb +32 -52
  41. data/lib/backup/notifier/hipchat.rb +99 -0
  42. data/lib/backup/notifier/mail.rb +100 -61
  43. data/lib/backup/notifier/presently.rb +31 -40
  44. data/lib/backup/notifier/prowl.rb +73 -0
  45. data/lib/backup/notifier/twitter.rb +29 -39
  46. data/lib/backup/packager.rb +25 -0
  47. data/lib/backup/splitter.rb +62 -0
  48. data/lib/backup/storage/base.rb +178 -18
  49. data/lib/backup/storage/cloudfiles.rb +34 -28
  50. data/lib/backup/storage/dropbox.rb +64 -67
  51. data/lib/backup/storage/ftp.rb +48 -40
  52. data/lib/backup/storage/local.rb +33 -28
  53. data/lib/backup/storage/ninefold.rb +40 -26
  54. data/lib/backup/storage/object.rb +8 -6
  55. data/lib/backup/storage/rsync.rb +61 -51
  56. data/lib/backup/storage/s3.rb +29 -27
  57. data/lib/backup/storage/scp.rb +56 -36
  58. data/lib/backup/storage/sftp.rb +49 -33
  59. data/lib/backup/syncer/base.rb +1 -1
  60. data/lib/backup/syncer/rsync.rb +1 -1
  61. data/lib/backup/template.rb +46 -0
  62. data/lib/backup/version.rb +1 -1
  63. data/spec/archive_spec.rb +34 -9
  64. data/spec/backup_spec.rb +1 -1
  65. data/spec/cli/helpers_spec.rb +35 -0
  66. data/spec/cli/utility_spec.rb +38 -0
  67. data/spec/compressor/bzip2_spec.rb +1 -1
  68. data/spec/compressor/gzip_spec.rb +1 -1
  69. data/spec/compressor/lzma_spec.rb +1 -1
  70. data/spec/compressor/pbzip2_spec.rb +63 -0
  71. data/spec/configuration/base_spec.rb +1 -1
  72. data/spec/configuration/compressor/bzip2_spec.rb +1 -1
  73. data/spec/configuration/compressor/gzip_spec.rb +1 -1
  74. data/spec/configuration/compressor/lzma_spec.rb +1 -1
  75. data/spec/configuration/database/base_spec.rb +1 -1
  76. data/spec/configuration/database/mongodb_spec.rb +1 -1
  77. data/spec/configuration/database/mysql_spec.rb +1 -1
  78. data/spec/configuration/database/postgresql_spec.rb +1 -1
  79. data/spec/configuration/database/redis_spec.rb +1 -1
  80. data/spec/configuration/database/riak_spec.rb +31 -0
  81. data/spec/configuration/encryptor/gpg_spec.rb +1 -1
  82. data/spec/configuration/encryptor/open_ssl_spec.rb +4 -1
  83. data/spec/configuration/notifier/campfire_spec.rb +1 -1
  84. data/spec/configuration/notifier/hipchat_spec.rb +43 -0
  85. data/spec/configuration/notifier/mail_spec.rb +34 -22
  86. data/spec/configuration/notifier/presently_spec.rb +1 -1
  87. data/spec/configuration/notifier/prowl_spec.rb +28 -0
  88. data/spec/configuration/notifier/twitter_spec.rb +1 -1
  89. data/spec/configuration/storage/cloudfiles_spec.rb +19 -16
  90. data/spec/configuration/storage/dropbox_spec.rb +1 -1
  91. data/spec/configuration/storage/ftp_spec.rb +1 -1
  92. data/spec/configuration/storage/local_spec.rb +1 -1
  93. data/spec/configuration/storage/ninefold_spec.rb +1 -1
  94. data/spec/configuration/storage/rsync_spec.rb +1 -1
  95. data/spec/configuration/storage/s3_spec.rb +1 -1
  96. data/spec/configuration/storage/scp_spec.rb +1 -1
  97. data/spec/configuration/storage/sftp_spec.rb +1 -1
  98. data/spec/configuration/syncer/rsync_spec.rb +1 -1
  99. data/spec/configuration/syncer/s3_spec.rb +1 -1
  100. data/spec/database/base_spec.rb +10 -1
  101. data/spec/database/mongodb_spec.rb +34 -7
  102. data/spec/database/mysql_spec.rb +8 -7
  103. data/spec/database/postgresql_spec.rb +8 -7
  104. data/spec/database/redis_spec.rb +39 -9
  105. data/spec/database/riak_spec.rb +50 -0
  106. data/spec/encryptor/gpg_spec.rb +1 -1
  107. data/spec/encryptor/open_ssl_spec.rb +77 -20
  108. data/spec/errors_spec.rb +306 -0
  109. data/spec/finder_spec.rb +91 -0
  110. data/spec/logger_spec.rb +254 -33
  111. data/spec/model_spec.rb +120 -15
  112. data/spec/notifier/campfire_spec.rb +127 -52
  113. data/spec/notifier/hipchat_spec.rb +193 -0
  114. data/spec/notifier/mail_spec.rb +290 -74
  115. data/spec/notifier/presently_spec.rb +290 -73
  116. data/spec/notifier/prowl_spec.rb +149 -0
  117. data/spec/notifier/twitter_spec.rb +106 -41
  118. data/spec/spec_helper.rb +8 -2
  119. data/spec/splitter_spec.rb +71 -0
  120. data/spec/storage/base_spec.rb +280 -19
  121. data/spec/storage/cloudfiles_spec.rb +38 -22
  122. data/spec/storage/dropbox_spec.rb +17 -13
  123. data/spec/storage/ftp_spec.rb +145 -55
  124. data/spec/storage/local_spec.rb +6 -6
  125. data/spec/storage/ninefold_spec.rb +70 -29
  126. data/spec/storage/object_spec.rb +44 -44
  127. data/spec/storage/rsync_spec.rb +186 -63
  128. data/spec/storage/s3_spec.rb +23 -24
  129. data/spec/storage/scp_spec.rb +116 -41
  130. data/spec/storage/sftp_spec.rb +124 -46
  131. data/spec/syncer/rsync_spec.rb +3 -3
  132. data/spec/syncer/s3_spec.rb +1 -1
  133. data/spec/version_spec.rb +1 -1
  134. data/templates/cli/utility/archive +13 -0
  135. data/{lib/templates → templates/cli/utility}/compressor/bzip2 +1 -1
  136. data/{lib/templates → templates/cli/utility}/compressor/gzip +1 -1
  137. data/{lib/templates → templates/cli/utility}/compressor/lzma +0 -0
  138. data/templates/cli/utility/compressor/pbzip2 +7 -0
  139. data/templates/cli/utility/config +31 -0
  140. data/{lib/templates → templates/cli/utility}/database/mongodb +1 -1
  141. data/{lib/templates → templates/cli/utility}/database/mysql +1 -1
  142. data/{lib/templates → templates/cli/utility}/database/postgresql +1 -1
  143. data/{lib/templates → templates/cli/utility}/database/redis +1 -1
  144. data/templates/cli/utility/database/riak +8 -0
  145. data/{lib/templates → templates/cli/utility}/encryptor/gpg +1 -1
  146. data/templates/cli/utility/encryptor/openssl +9 -0
  147. data/templates/cli/utility/model.erb +23 -0
  148. data/{lib/templates → templates/cli/utility}/notifier/campfire +2 -1
  149. data/templates/cli/utility/notifier/hipchat +15 -0
  150. data/{lib/templates → templates/cli/utility}/notifier/mail +6 -1
  151. data/{lib/templates → templates/cli/utility}/notifier/presently +1 -0
  152. data/templates/cli/utility/notifier/prowl +11 -0
  153. data/{lib/templates → templates/cli/utility}/notifier/twitter +2 -1
  154. data/templates/cli/utility/splitter +7 -0
  155. data/templates/cli/utility/storage/cloudfiles +12 -0
  156. data/{lib/templates → templates/cli/utility}/storage/dropbox +1 -1
  157. data/{lib/templates → templates/cli/utility}/storage/ftp +0 -0
  158. data/templates/cli/utility/storage/local +7 -0
  159. data/{lib/templates → templates/cli/utility}/storage/ninefold +1 -1
  160. data/templates/cli/utility/storage/rsync +11 -0
  161. data/{lib/templates → templates/cli/utility}/storage/s3 +0 -2
  162. data/templates/cli/utility/storage/scp +11 -0
  163. data/templates/cli/utility/storage/sftp +11 -0
  164. data/{lib/templates → templates/cli/utility}/syncer/rsync +1 -1
  165. data/{lib/templates → templates/cli/utility}/syncer/s3 +1 -1
  166. data/templates/general/links +11 -0
  167. data/templates/general/version.erb +2 -0
  168. data/templates/notifier/mail/failure.erb +9 -0
  169. data/templates/notifier/mail/success.erb +7 -0
  170. data/templates/notifier/mail/warning.erb +9 -0
  171. data/templates/storage/dropbox/authorization_url.erb +6 -0
  172. data/templates/storage/dropbox/authorized.erb +4 -0
  173. data/templates/storage/dropbox/cache_file_written.erb +10 -0
  174. metadata +81 -45
  175. data/lib/backup/cli.rb +0 -110
  176. data/lib/backup/exception/command_failed.rb +0 -8
  177. data/lib/backup/exception/command_not_found.rb +0 -8
  178. data/lib/backup/notifier/binder.rb +0 -32
  179. data/lib/backup/notifier/templates/notify_failure.erb +0 -33
  180. data/lib/backup/notifier/templates/notify_success.erb +0 -16
  181. data/lib/templates/archive +0 -7
  182. data/lib/templates/encryptor/openssl +0 -8
  183. data/lib/templates/readme +0 -15
  184. data/lib/templates/storage/cloudfiles +0 -11
  185. data/lib/templates/storage/local +0 -7
  186. data/lib/templates/storage/rsync +0 -11
  187. data/lib/templates/storage/scp +0 -11
  188. data/lib/templates/storage/sftp +0 -11
data/bin/backup CHANGED
@@ -1,288 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: utf-8
2
3
 
3
- ##
4
- # Load RubyGems for Ruby <= 1.8.7
5
- require 'rubygems'
6
- require 'tempfile'
7
- require 'fileutils'
8
-
9
- ##
10
- # Load Thor for the CLI and POpen4 for reading unix process status
11
- begin
12
- require 'thor'
13
- require 'popen4'
14
- rescue LoadError
15
- puts "\nBackup requires Thor to load the CLI (Command Line Interface) and POpen4 to determine the status of unix processes."
16
- puts "Please install both Thor and POpen4 first:\n\ngem install thor -v '~> 0.14.6'\ngem install popen4 -v '~> 0.1.2'"
17
- exit 1
18
- end
19
-
20
- ##
21
- # Load the Backup source
4
+ # Load the Backup core library
22
5
  require File.expand_path("../../lib/backup", __FILE__)
23
6
 
24
- ##
25
- # Build the Backup Command Line Interface using Thor
26
- class BackupCLI < Thor
27
- include Thor::Actions
28
-
29
- TEMPLATE_DIR = File.expand_path("../../lib/templates", __FILE__)
30
-
31
- ##
32
- # [Perform]
33
- # Performs the backup process. The only required option is the --trigger [-t].
34
- # If the other options (--config-file, --data-path, --cache--path, --tmp-path) aren't specified
35
- # it'll fallback to the (good) defaults
36
- method_option :trigger, :type => :string, :aliases => ['-t', '--triggers'], :required => true
37
- method_option :config_file, :type => :string, :aliases => '-c'
38
- method_option :data_path, :type => :string, :aliases => '-d'
39
- method_option :log_path, :type => :string, :aliases => '-l'
40
- method_option :cache_path, :type => :string
41
- method_option :tmp_path, :type => :string
42
- method_option :quiet, :type => :boolean, :aliases => '-q'
43
- desc 'perform', "Performs the backup for the specified trigger.\n" +
44
- "You may perform multiple backups by providing multiple triggers, separated by commas.\n\n" +
45
- "Example:\n\s\s$ backup perform --triggers backup1,backup2,backup3,backup4\n\n" +
46
- "This will invoke 4 backups, and they will run in the order specified (not asynchronous)."
47
- def perform
48
-
49
- ##
50
- # Overwrites the CONFIG_FILE location, if --config-file was specified
51
- if options[:config_file]
52
- Backup.send(:remove_const, :CONFIG_FILE)
53
- Backup.send(:const_set, :CONFIG_FILE, options[:config_file])
54
- end
55
-
56
- ##
57
- # Overwrites the DATA_PATH location, if --data-path was specified
58
- if options[:data_path]
59
- Backup.send(:remove_const, :DATA_PATH)
60
- Backup.send(:const_set, :DATA_PATH, options[:data_path])
61
- end
62
-
63
- ##
64
- # Overwrites the LOG_PATH location, if --log-path was specified
65
- if options[:log_path]
66
- Backup.send(:remove_const, :LOG_PATH)
67
- Backup.send(:const_set, :LOG_PATH, options[:log_path])
68
- end
69
-
70
- ##
71
- # Overwrites the CACHE_PATH location, if --cache-path was specified
72
- if options[:cache_path]
73
- Backup.send(:remove_const, :CACHE_PATH)
74
- Backup.send(:const_set, :CACHE_PATH, options[:cache_path])
75
- end
76
-
77
- ##
78
- # Overwrites the TMP_PATH location, if --tmp-path was specified
79
- if options[:tmp_path]
80
- Backup.send(:remove_const, :TMP_PATH)
81
- Backup.send(:const_set, :TMP_PATH, options[:tmp_path])
82
- end
83
-
84
- ##
85
- # Silence Backup::Logger from printing to STDOUT, if --quiet was specified
86
- if options[:quiet]
87
- Backup::Logger.send(:const_set, :QUIET, options[:quiet])
88
- end
89
-
90
- ##
91
- # Ensure the CACHE_PATH, TMP_PATH and LOG_PATH are created if they do not yet exist
92
- Array.new([Backup::CACHE_PATH, Backup::TMP_PATH, Backup::LOG_PATH]).each do |path|
93
- FileUtils.mkdir_p(path)
94
- end
95
-
96
- ##
97
- # Prepare all trigger names by splitting them by ','
98
- # and finding trigger names matching wildcard
99
- triggers = options[:trigger].split(",")
100
- triggers.map!(&:strip).map!{ |t|
101
- t.include?(Backup::Finder::WILDCARD) ?
102
- Backup::Finder.new(t).matching : t
103
- }.flatten!
104
-
105
- #triggers.unique! # Uncomment if its undesirable to call triggers twice
106
-
107
- ##
108
- # Process each trigger
109
- triggers.each do |trigger|
110
-
111
- ##
112
- # Defines the TRIGGER constant
113
- Backup.send(:const_set, :TRIGGER, trigger)
114
-
115
- ##
116
- # Define the TIME constants
117
- Backup.send(:const_set, :TIME, Time.now.strftime("%Y.%m.%d.%H.%M.%S"))
118
-
119
- ##
120
- # Ensure DATA_PATH and DATA_PATH/TRIGGER are created if they do not yet exist
121
- FileUtils.mkdir_p(File.join(Backup::DATA_PATH, Backup::TRIGGER))
122
-
123
- ##
124
- # Parses the backup configuration file and returns the model instance by trigger
125
- model = Backup::Finder.new(trigger).find
126
-
127
- ##
128
- # Runs the returned model
129
- Backup::Logger.message "Performing backup for #{model.label}!"
130
- model.perform!
131
-
132
- ##
133
- # Removes the TRIGGER constant
134
- Backup.send(:remove_const, :TRIGGER) if defined? Backup::TRIGGER
135
-
136
- ##
137
- # Removes the TIME constant
138
- Backup.send(:remove_const, :TIME) if defined? Backup::TIME
139
-
140
- ##
141
- # Reset the Backup::Model.current to nil for the next potential run
142
- Backup::Model.current = nil
143
-
144
- ##
145
- # Reset the Backup::Model.all to an empty array since this will be
146
- # re-filled during the next Backup::Finder.new(arg1, arg2).find
147
- Backup::Model.all = Array.new
148
-
149
- ##
150
- # Reset the Backup::Model.extension to 'tar' so it's at it's
151
- # initial state when the next Backup::Model initializes
152
- Backup::Model.extension = 'tar'
153
- end
154
- end
155
-
156
- ##
157
- # [Generate]
158
- # Generates a configuration file based on the arguments passed in.
159
- # For example, running $ backup generate --databases='mongodb' will generate a pre-populated
160
- # configuration file with a base MongoDB setup
161
- desc 'generate', 'Generates configuration blocks based on the arguments you pass in'
162
- method_option :path, :type => :string
163
- method_option :databases, :type => :string
164
- method_option :storages, :type => :string
165
- method_option :syncers, :type => :string
166
- method_option :encryptors, :type => :string
167
- method_option :compressors, :type => :string
168
- method_option :notifiers, :type => :string
169
- method_option :archives, :type => :boolean
170
- def generate
171
- temp_file = Tempfile.new('backup.rb')
172
- temp_file << File.read( File.join(TEMPLATE_DIR, 'readme') )
173
- temp_file << "Backup::Model.new(:my_backup, 'My Backup') do\n\n"
174
-
175
- if options[:archives]
176
- temp_file << File.read( File.join(TEMPLATE_DIR, 'archive') ) + "\n\n"
177
- end
178
-
179
- [:databases, :storages, :syncers, :encryptors, :compressors, :notifiers].each do |item|
180
- if options[item]
181
- options[item].split(',').map(&:strip).uniq.each do |entry|
182
- if File.exist?( File.join(TEMPLATE_DIR, item.to_s[0..-2], entry) )
183
- temp_file << File.read( File.join(TEMPLATE_DIR, item.to_s[0..-2], entry) ) + "\n\n"
184
- end
185
- end
186
- end
187
- end
188
-
189
- temp_file << "end\n\n"
190
- temp_file.close
191
-
192
- path = options[:path] || Backup::PATH
193
- config = File.join(path, 'config.rb')
194
-
195
- if overwrite?(config)
196
- FileUtils.mkdir_p(path)
197
- File.open(config, 'w') do |file|
198
- file.write( File.read(temp_file.path) )
199
- puts "Generated configuration file in '#{ config }'"
200
- end
201
- end
202
- temp_file.unlink
203
- end
204
-
205
- ##
206
- # [Decrypt]
207
- # Shorthand for decrypting encrypted files
208
- desc 'decrypt', 'Decrypts encrypted files'
209
- method_option :encryptor, :type => :string, :required => true
210
- method_option :in, :type => :string, :required => true
211
- method_option :out, :type => :string, :required => true
212
- method_option :base64, :type => :boolean, :default => false
213
- def decrypt
214
- case options[:encryptor].downcase
215
- when 'openssl'
216
- base64 = options[:base64] ? '-base64' : ''
217
- %x[openssl aes-256-cbc -d #{base64} -in '#{options[:in]}' -out '#{options[:out]}']
218
- when 'gpg'
219
- %x[gpg -o '#{options[:out]}' -d '#{options[:in]}']
220
- else
221
- puts "Unknown encryptor: #{options[:encryptor]}"
222
- puts "Use either 'openssl' or 'gpg'"
223
- end
224
- end
225
-
226
- ##
227
- # [Dependencies]
228
- # Returns a list of Backup's dependencies
229
- desc 'dependencies', 'Display the list of dependencies for Backup, or install them through Backup.'
230
- method_option :install, :type => :string
231
- method_option :list, :type => :boolean
232
- def dependencies
233
- unless options.any?
234
- puts
235
- puts "To display a list of available dependencies, run:\n\n"
236
- puts " backup dependencies --list"
237
- puts
238
- puts "To install one of these dependencies (with the correct version), run:\n\n"
239
- puts " backup dependencies --install <name>"
240
- exit
241
- end
242
-
243
- if options[:list]
244
- Backup::Dependency.all.each do |name, gemspec|
245
- puts
246
- puts name
247
- puts "--------------------------------------------------"
248
- puts "version: #{gemspec[:version]}"
249
- puts "lib required: #{gemspec[:require]}"
250
- puts "used for: #{gemspec[:for]}"
251
- end
252
- end
253
-
254
- if options[:install]
255
- puts
256
- puts "Installing \"#{options[:install]}\" version \"#{Backup::Dependency.all[options[:install]][:version]}\".."
257
- puts "If this doesn't work, please issue the following command yourself:\n\n"
258
- puts " gem install #{options[:install]} -v '#{Backup::Dependency.all[options[:install]][:version]}'\n\n"
259
- puts "Please wait..\n\n"
260
- puts %x[gem install #{options[:install]} -v '#{Backup::Dependency.all[options[:install]][:version]}']
261
- end
262
- end
263
-
264
- ##
265
- # [Version]
266
- # Returns the current version of the Backup gem
267
- map '-v' => :version
268
- desc 'version', 'Display installed Backup version'
269
- def version
270
- puts "Backup #{Backup::Version.current}"
271
- end
272
-
273
- private
274
-
275
- ##
276
- # Helper method for asking the user if he/she wants to overwrite the file
277
- def overwrite?(path)
278
- if File.exist?(path)
279
- return yes? "A configuration file already exists in #{ path }. Do you want to overwrite? [y/n]"
280
- end
281
- true
282
- end
283
-
284
- end
7
+ # Load the Backup command line interface utility
8
+ require File.expand_path("../../lib/backup/cli/utility", __FILE__)
285
9
 
286
- ##
287
- # Enable the CLI for the Backup binary
288
- BackupCLI.start
10
+ # Initialize the Backup command line utility
11
+ Backup::CLI::Utility.start
data/lib/backup.rb CHANGED
@@ -1,9 +1,24 @@
1
1
  # encoding: utf-8
2
2
 
3
+ # Load Ruby Core Libraries
4
+ require 'rubygems'
3
5
  require 'fileutils'
6
+ require 'tempfile'
4
7
  require 'yaml'
5
8
  require 'etc'
6
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
21
+
7
22
  ##
8
23
  # The Backup Ruby Gem
9
24
  module Backup
@@ -17,97 +32,57 @@ module Backup
17
32
  # database "MySQL" do |mysql|
18
33
  # You can do:
19
34
  # database MySQL do |mysql|
20
- DATABASES = ['MySQL', 'PostgreSQL', 'MongoDB', 'Redis']
35
+ DATABASES = ['MySQL', 'PostgreSQL', 'MongoDB', 'Redis', 'Riak']
21
36
  STORAGES = ['S3', 'CloudFiles', 'Ninefold', 'Dropbox', 'FTP', 'SFTP', 'SCP', 'RSync', 'Local']
22
- COMPRESSORS = ['Gzip', 'Bzip2', 'Lzma']
37
+ COMPRESSORS = ['Gzip', 'Bzip2', 'Pbzip2', 'Lzma']
23
38
  ENCRYPTORS = ['OpenSSL', 'GPG']
24
39
  SYNCERS = ['RSync', 'S3']
25
- NOTIFIERS = ['Mail', 'Twitter', 'Campfire', 'Presently']
40
+ NOTIFIERS = ['Mail', 'Twitter', 'Campfire', 'Presently', 'Prowl', 'Hipchat']
26
41
 
27
42
  ##
28
43
  # Backup's internal paths
29
44
  LIBRARY_PATH = File.join(File.dirname(__FILE__), 'backup')
30
- CONFIGURATION_PATH = File.join(LIBRARY_PATH, 'configuration')
45
+ CLI_PATH = File.join(LIBRARY_PATH, 'cli')
31
46
  STORAGE_PATH = File.join(LIBRARY_PATH, 'storage')
32
47
  DATABASE_PATH = File.join(LIBRARY_PATH, 'database')
33
48
  COMPRESSOR_PATH = File.join(LIBRARY_PATH, 'compressor')
34
49
  ENCRYPTOR_PATH = File.join(LIBRARY_PATH, 'encryptor')
35
50
  NOTIFIER_PATH = File.join(LIBRARY_PATH, 'notifier')
36
51
  SYNCER_PATH = File.join(LIBRARY_PATH, 'syncer')
37
- EXCEPTION_PATH = File.join(LIBRARY_PATH, 'exception')
52
+ CONFIGURATION_PATH = File.join(LIBRARY_PATH, 'configuration')
53
+ TEMPLATE_PATH = File.expand_path('../../templates', __FILE__)
38
54
 
39
55
  ##
40
56
  # Backup's Environment paths
41
57
  USER = ENV['USER'] || Etc.getpwuid.name
42
- PATH = File.join(ENV['HOME'], 'Backup')
43
- DATA_PATH = File.join(ENV['HOME'], 'Backup', 'data')
44
- CONFIG_FILE = File.join(ENV['HOME'], 'Backup', 'config.rb')
45
- LOG_PATH = File.join(ENV['HOME'], 'Backup', 'log')
46
- CACHE_PATH = File.join(ENV['HOME'], 'Backup', '.cache')
47
- TMP_PATH = File.join(ENV['HOME'], 'Backup', '.tmp')
58
+ HOME = File.expand_path(ENV['HOME'] || '')
59
+ PATH = File.join(HOME, 'Backup')
60
+ CONFIG_FILE = File.join(PATH, 'config.rb')
61
+ DATA_PATH = File.join(PATH, 'data')
62
+ LOG_PATH = File.join(PATH, 'log')
63
+ CACHE_PATH = File.join(PATH, '.cache')
64
+ TMP_PATH = File.join(PATH, '.tmp')
48
65
 
49
66
  ##
50
67
  # Autoload Backup base files
51
68
  autoload :Model, File.join(LIBRARY_PATH, 'model')
52
69
  autoload :Archive, File.join(LIBRARY_PATH, 'archive')
53
- autoload :CLI, File.join(LIBRARY_PATH, 'cli')
70
+ autoload :Packager, File.join(LIBRARY_PATH, 'packager')
71
+ autoload :Cleaner, File.join(LIBRARY_PATH, 'cleaner')
72
+ autoload :Splitter, File.join(LIBRARY_PATH, 'splitter')
54
73
  autoload :Finder, File.join(LIBRARY_PATH, 'finder')
74
+ autoload :Binder, File.join(LIBRARY_PATH, 'binder')
75
+ autoload :Template, File.join(LIBRARY_PATH, 'template')
55
76
  autoload :Dependency, File.join(LIBRARY_PATH, 'dependency')
56
77
  autoload :Logger, File.join(LIBRARY_PATH, 'logger')
57
78
  autoload :Version, File.join(LIBRARY_PATH, 'version')
79
+ autoload :Errors, File.join(LIBRARY_PATH, 'errors')
58
80
 
59
81
  ##
60
- # Autoload Backup configuration files
61
- module Configuration
62
- autoload :Base, File.join(CONFIGURATION_PATH, 'base')
63
- autoload :Helpers, File.join(CONFIGURATION_PATH, 'helpers')
64
-
65
- module Notifier
66
- autoload :Base, File.join(CONFIGURATION_PATH, 'notifier', 'base')
67
- autoload :Mail, File.join(CONFIGURATION_PATH, 'notifier', 'mail')
68
- autoload :Twitter, File.join(CONFIGURATION_PATH, 'notifier', 'twitter')
69
- autoload :Campfire, File.join(CONFIGURATION_PATH, 'notifier', 'campfire')
70
- autoload :Presently, File.join(CONFIGURATION_PATH, 'notifier', 'presently')
71
- end
72
-
73
- module Encryptor
74
- autoload :Base, File.join(CONFIGURATION_PATH, 'encryptor', 'base')
75
- autoload :OpenSSL, File.join(CONFIGURATION_PATH, 'encryptor', 'open_ssl')
76
- autoload :GPG, File.join(CONFIGURATION_PATH, 'encryptor', 'gpg')
77
- end
78
-
79
- module Compressor
80
- autoload :Base, File.join(CONFIGURATION_PATH, 'compressor', 'base')
81
- autoload :Gzip, File.join(CONFIGURATION_PATH, 'compressor', 'gzip')
82
- autoload :Bzip2, File.join(CONFIGURATION_PATH, 'compressor', 'bzip2')
83
- autoload :Lzma, File.join(CONFIGURATION_PATH, 'compressor', 'lzma')
84
- end
85
-
86
- module Storage
87
- autoload :Base, File.join(CONFIGURATION_PATH, 'storage', 'base')
88
- autoload :S3, File.join(CONFIGURATION_PATH, 'storage', 's3')
89
- autoload :CloudFiles, File.join(CONFIGURATION_PATH, 'storage', 'cloudfiles')
90
- autoload :Ninefold, File.join(CONFIGURATION_PATH, 'storage', 'ninefold')
91
- autoload :Dropbox, File.join(CONFIGURATION_PATH, 'storage', 'dropbox')
92
- autoload :FTP, File.join(CONFIGURATION_PATH, 'storage', 'ftp')
93
- autoload :SFTP, File.join(CONFIGURATION_PATH, 'storage', 'sftp')
94
- autoload :SCP, File.join(CONFIGURATION_PATH, 'storage', 'scp')
95
- autoload :RSync, File.join(CONFIGURATION_PATH, 'storage', 'rsync')
96
- autoload :Local, File.join(CONFIGURATION_PATH, 'storage', 'local')
97
- end
98
-
99
- module Syncer
100
- autoload :RSync, File.join(CONFIGURATION_PATH, 'syncer', 'rsync')
101
- autoload :S3, File.join(CONFIGURATION_PATH, 'syncer', 's3')
102
- end
103
-
104
- module Database
105
- autoload :Base, File.join(CONFIGURATION_PATH, 'database', 'base')
106
- autoload :MySQL, File.join(CONFIGURATION_PATH, 'database', 'mysql')
107
- autoload :PostgreSQL, File.join(CONFIGURATION_PATH, 'database', 'postgresql')
108
- autoload :MongoDB, File.join(CONFIGURATION_PATH, 'database', 'mongodb')
109
- autoload :Redis, File.join(CONFIGURATION_PATH, 'database', 'redis')
110
- end
82
+ # Autoload Backup CLI files
83
+ module CLI
84
+ autoload :Helpers, File.join(CLI_PATH, 'helpers')
85
+ autoload :Utility, File.join(CLI_PATH, 'utility')
111
86
  end
112
87
 
113
88
  ##
@@ -142,15 +117,17 @@ module Backup
142
117
  autoload :PostgreSQL, File.join(DATABASE_PATH, 'postgresql')
143
118
  autoload :MongoDB, File.join(DATABASE_PATH, 'mongodb')
144
119
  autoload :Redis, File.join(DATABASE_PATH, 'redis')
120
+ autoload :Riak, File.join(DATABASE_PATH, 'riak')
145
121
  end
146
122
 
147
123
  ##
148
124
  # Autoload compressor files
149
125
  module Compressor
150
- autoload :Base, File.join(COMPRESSOR_PATH, 'base')
151
- autoload :Gzip, File.join(COMPRESSOR_PATH, 'gzip')
152
- autoload :Bzip2, File.join(COMPRESSOR_PATH, 'bzip2')
153
- autoload :Lzma, File.join(COMPRESSOR_PATH, 'lzma')
126
+ autoload :Base, File.join(COMPRESSOR_PATH, 'base')
127
+ autoload :Gzip, File.join(COMPRESSOR_PATH, 'gzip')
128
+ autoload :Bzip2, File.join(COMPRESSOR_PATH, 'bzip2')
129
+ autoload :Pbzip2, File.join(COMPRESSOR_PATH, 'pbzip2')
130
+ autoload :Lzma, File.join(COMPRESSOR_PATH, 'lzma')
154
131
  end
155
132
 
156
133
  ##
@@ -170,13 +147,66 @@ module Backup
170
147
  autoload :Twitter, File.join(NOTIFIER_PATH, 'twitter')
171
148
  autoload :Campfire, File.join(NOTIFIER_PATH, 'campfire')
172
149
  autoload :Presently, File.join(NOTIFIER_PATH, 'presently')
150
+ autoload :Prowl, File.join(NOTIFIER_PATH, 'prowl')
151
+ autoload :Hipchat, File.join(NOTIFIER_PATH, 'hipchat')
173
152
  end
174
153
 
175
154
  ##
176
- # Autoload exception classes
177
- module Exception
178
- autoload :CommandNotFound, File.join(EXCEPTION_PATH, 'command_not_found')
179
- autoload :CommandFailed, File.join(EXCEPTION_PATH, 'command_failed')
155
+ # Autoload Backup configuration files
156
+ module Configuration
157
+ autoload :Base, File.join(CONFIGURATION_PATH, 'base')
158
+ autoload :Helpers, File.join(CONFIGURATION_PATH, 'helpers')
159
+
160
+ module Notifier
161
+ autoload :Base, File.join(CONFIGURATION_PATH, 'notifier', 'base')
162
+ autoload :Mail, File.join(CONFIGURATION_PATH, 'notifier', 'mail')
163
+ autoload :Twitter, File.join(CONFIGURATION_PATH, 'notifier', 'twitter')
164
+ autoload :Campfire, File.join(CONFIGURATION_PATH, 'notifier', 'campfire')
165
+ autoload :Presently, File.join(CONFIGURATION_PATH, 'notifier', 'presently')
166
+ autoload :Prowl, File.join(CONFIGURATION_PATH, 'notifier', 'prowl')
167
+ autoload :Hipchat, File.join(CONFIGURATION_PATH, 'notifier', 'hipchat')
168
+ end
169
+
170
+ module Encryptor
171
+ autoload :Base, File.join(CONFIGURATION_PATH, 'encryptor', 'base')
172
+ autoload :OpenSSL, File.join(CONFIGURATION_PATH, 'encryptor', 'open_ssl')
173
+ autoload :GPG, File.join(CONFIGURATION_PATH, 'encryptor', 'gpg')
174
+ end
175
+
176
+ module Compressor
177
+ autoload :Base, File.join(CONFIGURATION_PATH, 'compressor', 'base')
178
+ autoload :Gzip, File.join(CONFIGURATION_PATH, 'compressor', 'gzip')
179
+ autoload :Bzip2, File.join(CONFIGURATION_PATH, 'compressor', 'bzip2')
180
+ autoload :Pbzip2, File.join(CONFIGURATION_PATH, 'compressor', 'pbzip2')
181
+ autoload :Lzma, File.join(CONFIGURATION_PATH, 'compressor', 'lzma')
182
+ end
183
+
184
+ module Storage
185
+ autoload :Base, File.join(CONFIGURATION_PATH, 'storage', 'base')
186
+ autoload :S3, File.join(CONFIGURATION_PATH, 'storage', 's3')
187
+ autoload :CloudFiles, File.join(CONFIGURATION_PATH, 'storage', 'cloudfiles')
188
+ autoload :Ninefold, File.join(CONFIGURATION_PATH, 'storage', 'ninefold')
189
+ autoload :Dropbox, File.join(CONFIGURATION_PATH, 'storage', 'dropbox')
190
+ autoload :FTP, File.join(CONFIGURATION_PATH, 'storage', 'ftp')
191
+ autoload :SFTP, File.join(CONFIGURATION_PATH, 'storage', 'sftp')
192
+ autoload :SCP, File.join(CONFIGURATION_PATH, 'storage', 'scp')
193
+ autoload :RSync, File.join(CONFIGURATION_PATH, 'storage', 'rsync')
194
+ autoload :Local, File.join(CONFIGURATION_PATH, 'storage', 'local')
195
+ end
196
+
197
+ module Syncer
198
+ autoload :RSync, File.join(CONFIGURATION_PATH, 'syncer', 'rsync')
199
+ autoload :S3, File.join(CONFIGURATION_PATH, 'syncer', 's3')
200
+ end
201
+
202
+ module Database
203
+ autoload :Base, File.join(CONFIGURATION_PATH, 'database', 'base')
204
+ autoload :MySQL, File.join(CONFIGURATION_PATH, 'database', 'mysql')
205
+ autoload :PostgreSQL, File.join(CONFIGURATION_PATH, 'database', 'postgresql')
206
+ autoload :MongoDB, File.join(CONFIGURATION_PATH, 'database', 'mongodb')
207
+ autoload :Redis, File.join(CONFIGURATION_PATH, 'database', 'redis')
208
+ autoload :Riak, File.join(CONFIGURATION_PATH, 'database', 'riak')
209
+ end
180
210
  end
181
211
 
182
212
  ##
@@ -187,5 +217,4 @@ module Backup
187
217
  Backup::Finder.const_set(constant, Class.new)
188
218
  end
189
219
  end
190
-
191
220
  end