backup 3.0.27 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/LICENSE.md +1 -1
  2. data/README.md +139 -386
  3. data/bin/backup +1 -7
  4. data/lib/backup.rb +3 -9
  5. data/lib/backup/archive.rb +26 -20
  6. data/lib/backup/cleaner.rb +2 -2
  7. data/lib/backup/cli.rb +366 -0
  8. data/lib/backup/compressor/base.rb +2 -2
  9. data/lib/backup/compressor/gzip.rb +35 -1
  10. data/lib/backup/config.rb +1 -2
  11. data/lib/backup/database/base.rb +2 -2
  12. data/lib/backup/database/mongodb.rb +3 -3
  13. data/lib/backup/database/mysql.rb +3 -2
  14. data/lib/backup/database/postgresql.rb +3 -2
  15. data/lib/backup/database/riak.rb +18 -5
  16. data/lib/backup/dependency.rb +144 -93
  17. data/lib/backup/encryptor/base.rb +2 -2
  18. data/lib/backup/logger.rb +108 -110
  19. data/lib/backup/logger/console.rb +51 -0
  20. data/lib/backup/logger/logfile.rb +113 -0
  21. data/lib/backup/logger/syslog.rb +116 -0
  22. data/lib/backup/model.rb +67 -65
  23. data/lib/backup/notifier/base.rb +1 -1
  24. data/lib/backup/notifier/hipchat.rb +1 -1
  25. data/lib/backup/notifier/mail.rb +1 -1
  26. data/lib/backup/notifier/pushover.rb +6 -3
  27. data/lib/backup/packager.rb +4 -4
  28. data/lib/backup/pipeline.rb +17 -3
  29. data/lib/backup/splitter.rb +2 -2
  30. data/lib/backup/storage/base.rb +2 -2
  31. data/lib/backup/storage/cloudfiles.rb +2 -2
  32. data/lib/backup/storage/dropbox.rb +4 -4
  33. data/lib/backup/storage/ftp.rb +2 -2
  34. data/lib/backup/storage/local.rb +2 -2
  35. data/lib/backup/storage/ninefold.rb +2 -2
  36. data/lib/backup/storage/rsync.rb +3 -3
  37. data/lib/backup/storage/s3.rb +2 -2
  38. data/lib/backup/storage/scp.rb +2 -6
  39. data/lib/backup/storage/sftp.rb +2 -5
  40. data/lib/backup/syncer/base.rb +1 -1
  41. data/lib/backup/syncer/cloud/base.rb +15 -8
  42. data/lib/backup/syncer/rsync/local.rb +1 -1
  43. data/lib/backup/syncer/rsync/pull.rb +1 -1
  44. data/lib/backup/syncer/rsync/push.rb +1 -1
  45. data/lib/backup/utilities.rb +211 -0
  46. data/lib/backup/version.rb +1 -1
  47. data/templates/cli/{utility/archive → archive} +4 -8
  48. data/templates/cli/{utility/compressor → compressor}/bzip2 +0 -0
  49. data/templates/cli/{utility/compressor → compressor}/custom +0 -0
  50. data/templates/cli/{utility/compressor → compressor}/gzip +0 -0
  51. data/templates/cli/{utility/compressor → compressor}/lzma +0 -0
  52. data/templates/cli/{utility/compressor → compressor}/pbzip2 +0 -0
  53. data/templates/cli/config +68 -0
  54. data/templates/cli/{utility/database → database}/mongodb +1 -1
  55. data/templates/cli/{utility/database → database}/mysql +1 -1
  56. data/templates/cli/{utility/database → database}/postgresql +1 -1
  57. data/templates/cli/{utility/database → database}/redis +0 -0
  58. data/templates/cli/database/riak +20 -0
  59. data/templates/cli/{utility/encryptor → encryptor}/gpg +0 -0
  60. data/templates/cli/{utility/encryptor → encryptor}/openssl +0 -0
  61. data/templates/cli/{utility/model.erb → model.erb} +4 -4
  62. data/templates/cli/{utility/notifier → notifier}/campfire +0 -0
  63. data/templates/cli/{utility/notifier → notifier}/hipchat +0 -0
  64. data/templates/cli/{utility/notifier → notifier}/mail +0 -0
  65. data/templates/cli/{utility/notifier → notifier}/prowl +0 -0
  66. data/templates/cli/{utility/notifier → notifier}/pushover +0 -0
  67. data/templates/cli/{utility/notifier → notifier}/twitter +0 -0
  68. data/templates/cli/{utility/splitter → splitter} +0 -0
  69. data/templates/cli/{utility/storage → storage}/cloud_files +0 -0
  70. data/templates/cli/{utility/storage → storage}/dropbox +0 -0
  71. data/templates/cli/{utility/storage → storage}/ftp +0 -0
  72. data/templates/cli/{utility/storage → storage}/local +0 -0
  73. data/templates/cli/{utility/storage → storage}/ninefold +0 -0
  74. data/templates/cli/{utility/storage → storage}/rsync +0 -0
  75. data/templates/cli/{utility/storage → storage}/s3 +0 -0
  76. data/templates/cli/{utility/storage → storage}/scp +0 -0
  77. data/templates/cli/{utility/storage → storage}/sftp +0 -0
  78. data/templates/cli/{utility/syncer → syncer}/cloud_files +0 -0
  79. data/templates/cli/{utility/syncer → syncer}/rsync_local +0 -0
  80. data/templates/cli/{utility/syncer → syncer}/rsync_pull +0 -0
  81. data/templates/cli/{utility/syncer → syncer}/rsync_push +0 -0
  82. data/templates/cli/{utility/syncer → syncer}/s3 +0 -0
  83. metadata +55 -131
  84. data/.gitignore +0 -8
  85. data/.travis.yml +0 -10
  86. data/Gemfile +0 -28
  87. data/Guardfile +0 -23
  88. data/backup.gemspec +0 -32
  89. data/lib/backup/cli/helpers.rb +0 -93
  90. data/lib/backup/cli/utility.rb +0 -255
  91. data/spec-live/.gitignore +0 -6
  92. data/spec-live/README +0 -7
  93. data/spec-live/backups/config.rb +0 -83
  94. data/spec-live/backups/config.yml.template +0 -46
  95. data/spec-live/backups/models.rb +0 -184
  96. data/spec-live/compressor/custom_spec.rb +0 -30
  97. data/spec-live/compressor/gzip_spec.rb +0 -30
  98. data/spec-live/encryptor/gpg_keys.rb +0 -239
  99. data/spec-live/encryptor/gpg_spec.rb +0 -287
  100. data/spec-live/notifier/mail_spec.rb +0 -121
  101. data/spec-live/spec_helper.rb +0 -151
  102. data/spec-live/storage/dropbox_spec.rb +0 -151
  103. data/spec-live/storage/local_spec.rb +0 -83
  104. data/spec-live/storage/scp_spec.rb +0 -193
  105. data/spec-live/syncer/cloud/s3_spec.rb +0 -124
  106. data/spec/archive_spec.rb +0 -335
  107. data/spec/cleaner_spec.rb +0 -312
  108. data/spec/cli/helpers_spec.rb +0 -301
  109. data/spec/cli/utility_spec.rb +0 -411
  110. data/spec/compressor/base_spec.rb +0 -52
  111. data/spec/compressor/bzip2_spec.rb +0 -217
  112. data/spec/compressor/custom_spec.rb +0 -106
  113. data/spec/compressor/gzip_spec.rb +0 -217
  114. data/spec/compressor/lzma_spec.rb +0 -123
  115. data/spec/compressor/pbzip2_spec.rb +0 -165
  116. data/spec/config_spec.rb +0 -321
  117. data/spec/configuration/helpers_spec.rb +0 -247
  118. data/spec/configuration/store_spec.rb +0 -39
  119. data/spec/configuration_spec.rb +0 -62
  120. data/spec/database/base_spec.rb +0 -63
  121. data/spec/database/mongodb_spec.rb +0 -510
  122. data/spec/database/mysql_spec.rb +0 -411
  123. data/spec/database/postgresql_spec.rb +0 -353
  124. data/spec/database/redis_spec.rb +0 -334
  125. data/spec/database/riak_spec.rb +0 -176
  126. data/spec/dependency_spec.rb +0 -51
  127. data/spec/encryptor/base_spec.rb +0 -40
  128. data/spec/encryptor/gpg_spec.rb +0 -909
  129. data/spec/encryptor/open_ssl_spec.rb +0 -148
  130. data/spec/errors_spec.rb +0 -306
  131. data/spec/logger_spec.rb +0 -367
  132. data/spec/model_spec.rb +0 -666
  133. data/spec/notifier/base_spec.rb +0 -104
  134. data/spec/notifier/campfire_spec.rb +0 -217
  135. data/spec/notifier/hipchat_spec.rb +0 -211
  136. data/spec/notifier/mail_spec.rb +0 -316
  137. data/spec/notifier/prowl_spec.rb +0 -138
  138. data/spec/notifier/pushover_spec.rb +0 -123
  139. data/spec/notifier/twitter_spec.rb +0 -153
  140. data/spec/package_spec.rb +0 -61
  141. data/spec/packager_spec.rb +0 -213
  142. data/spec/pipeline_spec.rb +0 -259
  143. data/spec/spec_helper.rb +0 -60
  144. data/spec/splitter_spec.rb +0 -120
  145. data/spec/storage/base_spec.rb +0 -166
  146. data/spec/storage/cloudfiles_spec.rb +0 -254
  147. data/spec/storage/cycler_spec.rb +0 -247
  148. data/spec/storage/dropbox_spec.rb +0 -480
  149. data/spec/storage/ftp_spec.rb +0 -271
  150. data/spec/storage/local_spec.rb +0 -259
  151. data/spec/storage/ninefold_spec.rb +0 -343
  152. data/spec/storage/rsync_spec.rb +0 -362
  153. data/spec/storage/s3_spec.rb +0 -245
  154. data/spec/storage/scp_spec.rb +0 -233
  155. data/spec/storage/sftp_spec.rb +0 -244
  156. data/spec/syncer/base_spec.rb +0 -109
  157. data/spec/syncer/cloud/base_spec.rb +0 -515
  158. data/spec/syncer/cloud/cloud_files_spec.rb +0 -181
  159. data/spec/syncer/cloud/s3_spec.rb +0 -174
  160. data/spec/syncer/rsync/base_spec.rb +0 -98
  161. data/spec/syncer/rsync/local_spec.rb +0 -149
  162. data/spec/syncer/rsync/pull_spec.rb +0 -98
  163. data/spec/syncer/rsync/push_spec.rb +0 -333
  164. data/spec/version_spec.rb +0 -21
  165. data/templates/cli/utility/config +0 -32
  166. data/templates/cli/utility/database/riak +0 -11
@@ -68,7 +68,7 @@ module Backup
68
68
  directory = directory_for(remote_path, true)
69
69
 
70
70
  files_to_transfer_for(@package) do |local_file, remote_file|
71
- Logger.message "#{storage_name} started transferring '#{ local_file }'."
71
+ Logger.info "#{storage_name} started transferring '#{ local_file }'."
72
72
 
73
73
  File.open(File.join(local_path, local_file), 'r') do |file|
74
74
  directory.files.create(:key => remote_file, :body => file)
@@ -87,7 +87,7 @@ module Backup
87
87
  not_found = []
88
88
 
89
89
  transferred_files_for(package) do |local_file, remote_file|
90
- Logger.message "#{storage_name} started removing " +
90
+ Logger.info "#{storage_name} started removing " +
91
91
  "'#{ local_file }' from Ninefold."
92
92
 
93
93
  if file = directory.files.get(remote_file)
@@ -7,7 +7,7 @@ Backup::Dependency.load('net-ssh')
7
7
  module Backup
8
8
  module Storage
9
9
  class RSync < Base
10
- include Backup::CLI::Helpers
10
+ include Backup::Utilities::Helpers
11
11
 
12
12
  ##
13
13
  # Server credentials
@@ -68,14 +68,14 @@ module Backup
68
68
 
69
69
  files_to_transfer_for(@package) do |local_file, remote_file|
70
70
  if local
71
- Logger.message "#{storage_name} started transferring " +
71
+ Logger.info "#{storage_name} started transferring " +
72
72
  "'#{ local_file }' to '#{ remote_path }'."
73
73
  run(
74
74
  "#{ utility(:rsync) } '#{ File.join(local_path, local_file) }' " +
75
75
  "'#{ File.join(remote_path, remote_file) }'"
76
76
  )
77
77
  else
78
- Logger.message "#{storage_name} started transferring " +
78
+ Logger.info "#{storage_name} started transferring " +
79
79
  "'#{ local_file }' to '#{ ip }'."
80
80
  run(
81
81
  "#{ utility(:rsync) } #{ rsync_options } #{ rsync_port } " +
@@ -61,7 +61,7 @@ module Backup
61
61
  connection.sync_clock
62
62
 
63
63
  files_to_transfer_for(@package) do |local_file, remote_file|
64
- Logger.message "#{storage_name} started transferring " +
64
+ Logger.info "#{storage_name} started transferring " +
65
65
  "'#{ local_file }' to bucket '#{ bucket }'."
66
66
 
67
67
  File.open(File.join(local_path, local_file), 'r') do |file|
@@ -82,7 +82,7 @@ module Backup
82
82
  connection.sync_clock
83
83
 
84
84
  transferred_files_for(package) do |local_file, remote_file|
85
- Logger.message "#{storage_name} started removing " +
85
+ Logger.info "#{storage_name} started removing " +
86
86
  "'#{ local_file }' from bucket '#{ bucket }'."
87
87
 
88
88
  connection.delete_object(bucket, File.join(remote_path, remote_file))
@@ -1,9 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- ##
4
- # Only load the Net::SSH and Net::SCP library/gems
5
- # when the Backup::Storage::SCP class is loaded
6
- Backup::Dependency.load('net-ssh')
7
3
  Backup::Dependency.load('net-scp')
8
4
 
9
5
  module Backup
@@ -56,7 +52,7 @@ module Backup
56
52
  ssh.exec!("mkdir -p '#{ remote_path }'")
57
53
 
58
54
  files_to_transfer_for(@package) do |local_file, remote_file|
59
- Logger.message "#{storage_name} started transferring " +
55
+ Logger.info "#{storage_name} started transferring " +
60
56
  "'#{local_file}' to '#{ip}'."
61
57
 
62
58
  ssh.scp.upload!(
@@ -79,7 +75,7 @@ module Backup
79
75
  messages << "#{storage_name} started removing " +
80
76
  "'#{local_file}' from '#{ip}'."
81
77
  end
82
- Logger.message messages.join("\n")
78
+ Logger.info messages.join("\n")
83
79
 
84
80
  errors = []
85
81
  connection do |ssh|
@@ -1,8 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- ##
4
- # Only load the Net::SFTP library/gem when the Backup::Storage::SFTP class is loaded
5
- Backup::Dependency.load('net-ssh')
6
3
  Backup::Dependency.load('net-sftp')
7
4
 
8
5
  module Backup
@@ -55,7 +52,7 @@ module Backup
55
52
  create_remote_path(remote_path, sftp)
56
53
 
57
54
  files_to_transfer_for(@package) do |local_file, remote_file|
58
- Logger.message "#{storage_name} started transferring " +
55
+ Logger.info "#{storage_name} started transferring " +
59
56
  "'#{ local_file }' to '#{ ip }'."
60
57
 
61
58
  sftp.upload!(
@@ -75,7 +72,7 @@ module Backup
75
72
 
76
73
  connection do |sftp|
77
74
  transferred_files_for(package) do |local_file, remote_file|
78
- Logger.message "#{storage_name} started removing " +
75
+ Logger.info "#{storage_name} started removing " +
79
76
  "'#{ local_file }' from '#{ ip }'."
80
77
 
81
78
  sftp.remove!(File.join(remote_path, remote_file))
@@ -3,7 +3,7 @@
3
3
  module Backup
4
4
  module Syncer
5
5
  class Base
6
- include Backup::CLI::Helpers
6
+ include Backup::Utilities::Helpers
7
7
  include Backup::Configuration::Helpers
8
8
 
9
9
  ##
@@ -49,7 +49,7 @@ module Backup
49
49
  ##
50
50
  # Performs the Sync operation
51
51
  def perform!
52
- Logger.message(
52
+ Logger.info(
53
53
  "#{ syncer_name } started the syncing process:\n" +
54
54
  "\s\sConcurrency: #{ @concurrency_type } Level: #{ @concurrency_level }"
55
55
  )
@@ -60,12 +60,14 @@ module Backup
60
60
  ).sync! @mirror, @concurrency_type, @concurrency_level
61
61
  end
62
62
 
63
- Logger.message("#{ syncer_name } Syncing Complete!")
63
+ Logger.info("#{ syncer_name } Syncing Complete!")
64
64
  end
65
65
 
66
66
  private
67
67
 
68
68
  class SyncContext
69
+ include Utilities::Helpers
70
+
69
71
  attr_reader :directory, :bucket, :path, :remote_base
70
72
 
71
73
  ##
@@ -126,9 +128,14 @@ module Backup
126
128
 
127
129
  ##
128
130
  # Returns a String of file paths and their md5 hashes.
131
+ #
132
+ # Utilities#run is not used here because this would produce too much
133
+ # log output, and Pipeline does not support capturing output.
129
134
  def local_hashes
130
- Logger.message("\s\sGenerating checksums for '#{ @directory }'")
131
- `find '#{ @directory }' -print0 | xargs -0 openssl md5 2> /dev/null`
135
+ Logger.info("\s\sGenerating checksums for '#{ @directory }'")
136
+ cmd = "#{ utility(:find) } -L '#{ @directory }' -type f -print0 | " +
137
+ "#{ utility(:xargs) } -0 #{ utility(:openssl) } md5 2> /dev/null"
138
+ %x[#{ cmd }]
132
139
  end
133
140
 
134
141
  ##
@@ -160,7 +167,7 @@ module Backup
160
167
  if local_file && File.exist?(local_file.path)
161
168
  unless remote_file && remote_file.etag == local_file.md5
162
169
  MUTEX.synchronize {
163
- Logger.message("\s\s[transferring] '#{ remote_path }'")
170
+ Logger.info("\s\s[transferring] '#{ remote_path }'")
164
171
  }
165
172
  File.open(local_file.path, 'r') do |file|
166
173
  @bucket.files.create(
@@ -170,18 +177,18 @@ module Backup
170
177
  end
171
178
  else
172
179
  MUTEX.synchronize {
173
- Logger.message("\s\s[skipping] '#{ remote_path }'")
180
+ Logger.info("\s\s[skipping] '#{ remote_path }'")
174
181
  }
175
182
  end
176
183
  elsif remote_file
177
184
  if mirror
178
185
  MUTEX.synchronize {
179
- Logger.message("\s\s[removing] '#{ remote_path }'")
186
+ Logger.info("\s\s[removing] '#{ remote_path }'")
180
187
  }
181
188
  remote_file.destroy
182
189
  else
183
190
  MUTEX.synchronize {
184
- Logger.message("\s\s[leaving] '#{ remote_path }'")
191
+ Logger.info("\s\s[leaving] '#{ remote_path }'")
185
192
  }
186
193
  end
187
194
  end
@@ -25,7 +25,7 @@ module Backup
25
25
  # Performs the RSync::Local operation
26
26
  # debug options: -vhP
27
27
  def perform!
28
- Logger.message(
28
+ Logger.info(
29
29
  "#{ syncer_name } started syncing the following directories:\n\s\s" +
30
30
  @directories.join("\n\s\s")
31
31
  )
@@ -12,7 +12,7 @@ module Backup
12
12
  write_password_file!
13
13
 
14
14
  @directories.each do |directory|
15
- Logger.message("#{ syncer_name } started syncing '#{ directory }'.")
15
+ Logger.info("#{ syncer_name } started syncing '#{ directory }'.")
16
16
  run("#{ utility(:rsync) } #{ options } " +
17
17
  "'#{ username }@#{ ip }:#{ directory.sub(/^\~\//, '') }' " +
18
18
  "'#{ dest_path }'")
@@ -47,7 +47,7 @@ module Backup
47
47
  def perform!
48
48
  write_password_file!
49
49
 
50
- Logger.message(
50
+ Logger.info(
51
51
  "#{ syncer_name } started syncing the following directories:\n\s\s" +
52
52
  @directories.join("\n\s\s")
53
53
  )
@@ -0,0 +1,211 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Utilities
5
+ UTILITY = {}
6
+ NAMES = %w{
7
+ tar cat split find xargs
8
+ gzip bzip2 lzma pbzip2
9
+ mongo mongodump mysqldump pg_dump redis-cli riak-admin
10
+ gpg openssl
11
+ rsync
12
+ }
13
+
14
+ module Helpers
15
+ private
16
+
17
+ ##
18
+ # Returns the full path to the specified utility.
19
+ # Raises an error if utility can not be found in the system's $PATH
20
+ def utility(name)
21
+ name = name.to_s.strip
22
+ raise Errors::Utilities::NotFoundError,
23
+ 'Utility Name Empty' if name.empty?
24
+
25
+ path = UTILITY[name] || %x[which '#{ name }' 2>/dev/null].chomp
26
+ if path.empty?
27
+ raise Errors::Utilities::NotFoundError, <<-EOS
28
+ Could not locate '#{ name }'.
29
+ Make sure the specified utility is installed
30
+ and available in your system's $PATH.
31
+ EOS
32
+ end
33
+ UTILITY[name] = path
34
+ end
35
+
36
+ ##
37
+ # Returns the name of the command name from the given command line
38
+ def command_name(command)
39
+ i = command =~ /\s/
40
+ command = command.slice(0, i) if i
41
+ command.split('/')[-1]
42
+ end
43
+
44
+ ##
45
+ # Runs a system command
46
+ #
47
+ # All messages generated by the command will be logged.
48
+ # Messages on STDERR will be logged as warnings.
49
+ #
50
+ # If the command fails to execute, or returns a non-zero exit status
51
+ # an Error will be raised.
52
+ #
53
+ # Returns STDOUT
54
+ def run(command)
55
+ name = command_name(command)
56
+ Logger.info "Running system utility '#{ name }'..."
57
+
58
+ begin
59
+ out, err = '', ''
60
+ # popen4 doesn't work in 1.8.7 with stock versions of ruby shipped
61
+ # with major OSs. Hack to make it stop segfaulting.
62
+ # See: https://github.com/engineyard/engineyard/issues/115
63
+ GC.disable if RUBY_VERSION < '1.9'
64
+ ps = Open4.popen4(command) do |pid, stdin, stdout, stderr|
65
+ stdin.close
66
+ out, err = stdout.read.strip, stderr.read.strip
67
+ end
68
+ rescue Exception => e
69
+ raise Errors::Utilities::SystemCallError.wrap(e, <<-EOS)
70
+ Failed to execute system command on #{ RUBY_PLATFORM }
71
+ Command was: #{ command }
72
+ EOS
73
+ ensure
74
+ GC.enable if RUBY_VERSION < '1.9'
75
+ end
76
+
77
+ if ps.success?
78
+ unless out.empty?
79
+ Logger.info(
80
+ out.lines.map {|line| "#{ name }:STDOUT: #{ line }" }.join
81
+ )
82
+ end
83
+
84
+ unless err.empty?
85
+ Logger.warn(
86
+ err.lines.map {|line| "#{ name }:STDERR: #{ line }" }.join
87
+ )
88
+ end
89
+
90
+ return out
91
+ else
92
+ raise Errors::Utilities::SystemCallError, <<-EOS
93
+ '#{ name }' Failed on #{ RUBY_PLATFORM }
94
+ The following information should help to determine the problem:
95
+ Command was: #{ command }
96
+ Exit Status: #{ ps.exitstatus }
97
+ STDOUT Messages: #{ out.empty? ? 'None' : "\n#{ out }" }
98
+ STDERR Messages: #{ err.empty? ? 'None' : "\n#{ err }" }
99
+ EOS
100
+ end
101
+ end
102
+
103
+ def gnu_tar?
104
+ Utilities.gnu_tar?
105
+ end
106
+ end # Helpers
107
+
108
+ class << self
109
+ include Helpers
110
+
111
+ ##
112
+ # Configure the path to system utilities used by Backup.
113
+ #
114
+ # Backup will attempt to locate any required system utilities using a
115
+ # +which+ command call. If a utility can not be found, or you need to
116
+ # specify an alternate path for a utility, you may do so in your
117
+ # +config.rb+ file using this method.
118
+ #
119
+ # Backup supports both GNU and BSD utilities.
120
+ # While Backup uses these utilities in a manner compatible with either
121
+ # version, the +tar+ utility requires some special handling with respect
122
+ # to +Archive+s. Backup will attempt to detect if the +tar+ command
123
+ # found (or set here) is GNU or BSD. If for some reason this fails,
124
+ # this may be set using the +tar_dist+ command shown below.
125
+ #
126
+ # Backup::Utilities.configure do
127
+ # # General Utilites
128
+ # tar '/path/to/tar'
129
+ # tar_dist :gnu # or :bsd
130
+ # cat '/path/to/cat'
131
+ # split '/path/to/split'
132
+ # find '/path/to/find'
133
+ # xargs '/path/to/xargs'
134
+ #
135
+ # # Compressors
136
+ # gzip '/path/to/gzip'
137
+ # bzip2 '/path/to/bzip2'
138
+ # lzma '/path/to/lzma' # deprecated. use a Custom Compressor
139
+ # pbzip2 '/path/to/pbzip2' # deprecated. use a Custom Compressor
140
+ #
141
+ # # Database Utilities
142
+ # mongo '/path/to/mongo'
143
+ # mongodump '/path/to/mongodump'
144
+ # mysqldump '/path/to/mysqldump'
145
+ # pg_dump '/path/to/pg_dump'
146
+ # redis_cli '/path/to/redis-cli'
147
+ # riak_admin '/path/to/riak-admin'
148
+ #
149
+ # # Encryptors
150
+ # gpg '/path/to/gpg'
151
+ # openssl '/path/to/openssl'
152
+ #
153
+ # # Syncer and Storage
154
+ # rsync '/path/to/rsync'
155
+ # end
156
+ #
157
+ # These paths may be set using absolute paths, or relative to the
158
+ # working directory when Backup is run.
159
+ #
160
+ # Note that many of Backup's components currently have their own
161
+ # configuration settings for utility paths. For instance, when configuring
162
+ # a +MySQL+ database backup, +mysqldump_utility+ may be used:
163
+ #
164
+ # database MySQL do |db|
165
+ # db.mysqldump_utility = '/path/to/mysqldump'
166
+ # end
167
+ #
168
+ # Use of these configuration settings will override the path set here.
169
+ # (The use of these may be deprecated in the future)
170
+ def configure(&block)
171
+ instance_eval(&block)
172
+ end
173
+
174
+ def gnu_tar?
175
+ return @gnu_tar unless @gnu_tar.nil?
176
+ @gnu_tar = !!run("#{ utility(:tar) } --version").match(/GNU/)
177
+ end
178
+
179
+ private
180
+
181
+ ##
182
+ # Allow users to set the path for all utilities in the .configure block.
183
+ #
184
+ # Utility names with dashes ('redis-cli') will be set using method calls
185
+ # with an underscore ('redis_cli').
186
+ NAMES.each do |name|
187
+ define_method name.gsub('-', '_'), lambda {|val|
188
+ path = File.expand_path(val)
189
+ unless File.executable?(path)
190
+ raise Errors::Utilities::NotFoundError, <<-EOS
191
+ The path given for '#{ name }' was not found or not executable.
192
+ Path was: #{ path }
193
+ EOS
194
+ end
195
+ UTILITY[name] = path
196
+ }
197
+ end
198
+
199
+ ##
200
+ # Allow users to set the +tar+ distribution if needed. (:gnu or :bsd)
201
+ def tar_dist(val)
202
+ @gnu_tar = val == :gnu
203
+ end
204
+
205
+ def reset!
206
+ UTILITY.clear
207
+ @gnu_tar = nil
208
+ end
209
+ end
210
+ end
211
+ end
@@ -13,7 +13,7 @@ module Backup
13
13
  # Defines the minor version
14
14
  # PATCH:
15
15
  # Defines the patch version
16
- MAJOR, MINOR, PATCH = 3, 0, 27
16
+ MAJOR, MINOR, PATCH = 3, 1, 0
17
17
 
18
18
  ##
19
19
  # Returns the major version ( big release based off of multiple minor releases )