backup 3.9.0 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11a5142174a679705cd2443ac0248928a6c5f8b8
4
- data.tar.gz: 7e6b4a5a23ab07ecd0e0cdaf96e537b721b6d3bc
3
+ metadata.gz: d08ea59b9238db092857f8ee08a10f1c695d1705
4
+ data.tar.gz: 8030b371b0b43a7ba075927af576265d5ddf8969
5
5
  SHA512:
6
- metadata.gz: 18b022a990ce3a8c6010a3d7ea25bce8eca33d1552b03f852e3c02a077ac73b6788ff0d841f5f097b56536282fe1f997dcfeebd4fa1954aa18fc8553ba8f513e
7
- data.tar.gz: 710399d76701426778abf1a6713a59b9f01dd532ec00a1fb2d8d2035d421441ffd0a2288fab472a68af649817086461c05e34770db6c8e7bf6698e5a2851eeb9
6
+ metadata.gz: 8f76e9862b4784775aecd53127ebe9c478f378a7162348d88bd2fd5e0b515b144deb89dd89c68d7b4592f0f8d94eda4ac228bee29f204a240ab635038089ed27
7
+ data.tar.gz: 13c73bfd31689f46c9f0c809849e59180a1e4eebeb0af05650dae7a8948895f2dc5e80e08c6a67c16a5028fb6b58269be05f49f56d8fc3a7b6782730890a1e3c
@@ -106,7 +106,7 @@ module Backup
106
106
  until keys.empty?
107
107
  _keys = keys.slice!(0, 1000)
108
108
  with_retries('DELETE Multiple Objects') do
109
- resp = connection.delete_multiple_objects(bucket, _keys, opts)
109
+ resp = connection.delete_multiple_objects(bucket, _keys, opts.dup)
110
110
  unless resp.body['DeleteResult'].empty?
111
111
  errors = resp.body['DeleteResult'].map do |result|
112
112
  error = result['Error']
@@ -72,6 +72,15 @@ module Backup
72
72
  Response was: #{ resp }
73
73
  EOS
74
74
  end
75
+
76
+ rescue Error
77
+ if resp =~ /save already in progress/
78
+ unless (attempts ||= '0').next! == '5'
79
+ sleep 5
80
+ retry
81
+ end
82
+ end
83
+ raise
75
84
  end
76
85
 
77
86
  def copy!
@@ -202,15 +202,19 @@ module Backup
202
202
  end
203
203
 
204
204
  ##
205
- # Adds a Splitter with the given +chunk_size+ in MB.
206
- # This will split the final backup package into multiple files.
207
- def split_into_chunks_of(chunk_size)
208
- if chunk_size.is_a?(Integer)
209
- @splitter = Splitter.new(self, chunk_size)
205
+ # Adds a Splitter to split the final backup package into multiple files.
206
+ #
207
+ # +chunk_size+ is specified in MiB and must be given as an Integer.
208
+ # +suffix_length+ controls the number of characters used in the suffix
209
+ # (and the maximum number of chunks possible).
210
+ # ie. 1 (-a, -b), 2 (-aa, -ab), 3 (-aaa, -aab)
211
+ def split_into_chunks_of(chunk_size, suffix_length = 2)
212
+ if chunk_size.is_a?(Integer) && suffix_length.is_a?(Integer)
213
+ @splitter = Splitter.new(self, chunk_size, suffix_length)
210
214
  else
211
215
  raise Error, <<-EOS
212
- Invalid Chunk Size for Splitter
213
- Argument to #split_into_chunks_of() must be an Integer
216
+ Invalid arguments for #split_into_chunks_of()
217
+ +chunk_size+ (and optional +suffix_length+) must be Integers.
214
218
  EOS
215
219
  end
216
220
  end
@@ -4,22 +4,25 @@ module Backup
4
4
  class Splitter
5
5
  include Backup::Utilities::Helpers
6
6
 
7
- attr_reader :package, :chunk_size
7
+ attr_reader :package, :chunk_size, :suffix_length
8
8
 
9
- def initialize(model, chunk_size)
9
+ def initialize(model, chunk_size, suffix_length)
10
10
  @package = model.package
11
11
  @chunk_size = chunk_size
12
+ @suffix_length = suffix_length
12
13
  end
13
14
 
14
15
  ##
15
16
  # This is called as part of the procedure used to build the final
16
17
  # backup package file(s). It yields it's portion of the command line
17
18
  # for this procedure, which will split the data being piped into it
18
- # into multiple files, based on the @chunk_size.
19
+ # into multiple files, based on the @chunk_size, using a suffix length as
20
+ # specified by @suffix_length.
19
21
  # Once the packaging procedure is complete, it will return and
20
22
  # @package.chunk_suffixes will be set based on the resulting files.
21
23
  def split_with
22
- Logger.info "Splitter configured with a chunk size of #{ chunk_size }MB."
24
+ Logger.info "Splitter configured with a chunk size of #{ chunk_size }MB " +
25
+ "and suffix length of #{ suffix_length }."
23
26
  yield split_command
24
27
  after_packaging
25
28
  end
@@ -28,12 +31,10 @@ module Backup
28
31
 
29
32
  ##
30
33
  # The `split` command reads from $stdin and will store it's output in
31
- # multiple files, based on the @chunk_size. The files will be
32
- # written using the given `prefix`, which is the full path to the
33
- # final @package.basename, plus a '-' separator. This `prefix` will then
34
- # be suffixed using 'aa', 'ab', and so on... for each file.
34
+ # multiple files, based on @chunk_size and @suffix_length, using the full
35
+ # path to the final @package.basename, plus a '-' separator as the `prefix`.
35
36
  def split_command
36
- "#{ utility(:split) } -b #{ chunk_size }m - " +
37
+ "#{ utility(:split) } -a #{ suffix_length } -b #{ chunk_size }m - " +
37
38
  "'#{ File.join(Config.tmp_path, package.basename + '-') }'"
38
39
  end
39
40
 
@@ -41,13 +42,15 @@ module Backup
41
42
  # Finds the resulting files from the packaging procedure
42
43
  # and stores an Array of suffixes used in @package.chunk_suffixes.
43
44
  # If the @chunk_size was never reached and only one file
44
- # was written, that file will be suffixed with '-aa'.
45
- # In which case, it will simply remove the suffix from the filename.
45
+ # was written, that file will be suffixed with '-aa' (or -a; -aaa; etc
46
+ # depending upon suffix_length). In which case, it will simply
47
+ # remove the suffix from the filename.
46
48
  def after_packaging
47
49
  suffixes = chunk_suffixes
48
- if suffixes == ['aa']
50
+ first_suffix = 'a' * suffix_length
51
+ if suffixes == [first_suffix]
49
52
  FileUtils.mv(
50
- File.join(Config.tmp_path, package.basename + '-aa'),
53
+ File.join(Config.tmp_path, "#{ package.basename }-#{ first_suffix }"),
51
54
  File.join(Config.tmp_path, package.basename)
52
55
  )
53
56
  else
@@ -57,7 +60,7 @@ module Backup
57
60
 
58
61
  ##
59
62
  # Returns an array of suffixes for each chunk, in alphabetical order.
60
- # For example: [aa, ab, ac, ad, ae]
63
+ # For example: [aa, ab, ac, ad, ae] or [aaa, aab, aac aad]
61
64
  def chunk_suffixes
62
65
  chunks.map {|chunk| File.extname(chunk).split('-').last }.sort
63
66
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Backup
4
- VERSION = '3.9.0'
4
+ VERSION = '3.10.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-11 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -511,7 +511,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
511
511
  version: '0'
512
512
  requirements: []
513
513
  rubyforge_project:
514
- rubygems_version: 2.1.1
514
+ rubygems_version: 2.1.11
515
515
  signing_key:
516
516
  specification_version: 4
517
517
  summary: Provides an elegant DSL in Ruby for performing backups on UNIX-like systems.