backup 3.8.0 → 3.9.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: 697c751e37f7ee0a9c4485ba7c793980a7a5b087
4
- data.tar.gz: 2bc9a792c855ed04d7d8e32a95612b7510836a93
3
+ metadata.gz: 11a5142174a679705cd2443ac0248928a6c5f8b8
4
+ data.tar.gz: 7e6b4a5a23ab07ecd0e0cdaf96e537b721b6d3bc
5
5
  SHA512:
6
- metadata.gz: 66fee3c688e30e8c0dca0083d3b65b989578f9cdb42b6d043e6d6880e129bfa2ee08b220ee1b778322f02d52b58ad119a33a46458ced5f4e24663122963f9a1e
7
- data.tar.gz: 44d7d2382a074f6f5e83df6b360d26137c6bc2733031cb2b22ce0f5ce1d83b97712366254f248ceb6681aaf5f8d42fcd138484b670bb52acab51d5fdbfe8026b
6
+ metadata.gz: 18b022a990ce3a8c6010a3d7ea25bce8eca33d1552b03f852e3c02a077ac73b6788ff0d841f5f097b56536282fe1f997dcfeebd4fa1954aa18fc8553ba8f513e
7
+ data.tar.gz: 710399d76701426778abf1a6713a59b9f01dd532ec00a1fb2d8d2035d421441ffd0a2288fab472a68af649817086461c05e34770db6c8e7bf6698e5a2851eeb9
@@ -13,7 +13,8 @@ module Backup
13
13
  SEGMENT_BUFFER = 1024**2 # 1 MiB
14
14
 
15
15
  attr_reader :username, :api_key, :auth_url, :region, :servicenet,
16
- :container, :segments_container, :segment_size, :days_to_keep
16
+ :container, :segments_container, :segment_size, :days_to_keep,
17
+ :fog_options
17
18
 
18
19
  def initialize(options = {})
19
20
  super
@@ -27,6 +28,7 @@ module Backup
27
28
  @segments_container = options[:segments_container]
28
29
  @segment_size = options[:segment_size]
29
30
  @days_to_keep = options[:days_to_keep]
31
+ @fog_options = options[:fog_options]
30
32
  end
31
33
 
32
34
  # The Syncer may call this method in multiple threads,
@@ -139,14 +141,14 @@ module Backup
139
141
  private
140
142
 
141
143
  def connection
142
- @connection ||= Fog::Storage.new(
144
+ @connection ||= Fog::Storage.new({
143
145
  :provider => 'Rackspace',
144
146
  :rackspace_username => username,
145
147
  :rackspace_api_key => api_key,
146
148
  :rackspace_auth_url => auth_url,
147
149
  :rackspace_region => region,
148
150
  :rackspace_servicenet => servicenet
149
- )
151
+ }.merge(fog_options || {}))
150
152
  end
151
153
 
152
154
  def create_containers
@@ -14,7 +14,8 @@ module Backup
14
14
  MAX_MULTIPART_SIZE = 1024**4 * 5 # 5 TiB
15
15
 
16
16
  attr_reader :access_key_id, :secret_access_key, :use_iam_profile,
17
- :region, :bucket, :chunk_size, :encryption, :storage_class
17
+ :region, :bucket, :chunk_size, :encryption, :storage_class,
18
+ :fog_options
18
19
 
19
20
  def initialize(options = {})
20
21
  super
@@ -27,6 +28,7 @@ module Backup
27
28
  @chunk_size = options[:chunk_size]
28
29
  @encryption = options[:encryption]
29
30
  @storage_class = options[:storage_class]
31
+ @fog_options = options[:fog_options]
30
32
  end
31
33
 
32
34
  # The Syncer may call this method in multiple threads.
@@ -130,6 +132,7 @@ module Backup
130
132
  :aws_secret_access_key => secret_access_key
131
133
  )
132
134
  end
135
+ opts.merge!(fog_options || {})
133
136
  conn = Fog::Storage.new(opts)
134
137
  conn.sync_clock
135
138
  conn
@@ -38,6 +38,22 @@ module Backup
38
38
  module_eval(File.read(@config_file), @config_file)
39
39
  end
40
40
 
41
+ # Allows users to create preconfigured models.
42
+ def preconfigure(name, &block)
43
+ unless name.is_a?(String) && name =~ /^[A-Z]/
44
+ raise Error, "Preconfigured model names must be given as a string " +
45
+ " and start with a capital letter."
46
+ end
47
+
48
+ if Backup.const_defined?(name)
49
+ raise Error, "'#{ name }' is already in use " +
50
+ "and can not be used for a preconfigured model."
51
+ end
52
+
53
+ Backup.const_set(name, Class.new(Model))
54
+ Backup.const_get(name).preconfigure(&block)
55
+ end
56
+
41
57
  def hostname
42
58
  @hostname ||= run(utility(:hostname))
43
59
  end
@@ -25,6 +25,18 @@ module Backup
25
25
  all.select {|model| trigger == model.trigger }
26
26
  end
27
27
  end
28
+
29
+ # Allows users to create preconfigured models.
30
+ def preconfigure(&block)
31
+ @preconfigure ||= block
32
+ end
33
+
34
+ private
35
+
36
+ # used for testing
37
+ def reset!
38
+ @all = @preconfigure = nil
39
+ end
28
40
  end
29
41
 
30
42
  ##
@@ -111,6 +123,7 @@ module Backup
111
123
  @notifiers = []
112
124
  @syncers = []
113
125
 
126
+ instance_eval(&self.class.preconfigure) if self.class.preconfigure
114
127
  instance_eval(&block) if block_given?
115
128
 
116
129
  # trigger all defined databases to generate their #dump_filename
@@ -214,7 +227,8 @@ module Backup
214
227
  #
215
228
  # If any exception is raised, any defined +after+ hook will be skipped.
216
229
  def before(&block)
217
- @before ||= block
230
+ @before = block if block
231
+ @before
218
232
  end
219
233
 
220
234
  ##
@@ -241,7 +255,8 @@ module Backup
241
255
  # the exit_status will be elevated to 2. If the exception is not a
242
256
  # StandardError, the exit_status will be elevated to 3.
243
257
  def after(&block)
244
- @after ||= block
258
+ @after = block if block
259
+ @after
245
260
  end
246
261
 
247
262
  ##
@@ -65,6 +65,11 @@ module Backup
65
65
  # Default: 30
66
66
  attr_accessor :retry_waitsec
67
67
 
68
+ ##
69
+ # Additional options to pass along to fog.
70
+ # e.g. Fog::Storage.new({ :provider => 'Rackspace' }.merge(fog_options))
71
+ attr_accessor :fog_options
72
+
68
73
  def initialize(model, storage_id = nil)
69
74
  super
70
75
 
@@ -93,7 +98,8 @@ module Backup
93
98
  :segment_size => segment_size,
94
99
  :days_to_keep => days_to_keep,
95
100
  :max_retries => max_retries,
96
- :retry_waitsec => retry_waitsec
101
+ :retry_waitsec => retry_waitsec,
102
+ :fog_options => fog_options
97
103
  )
98
104
  end
99
105
 
@@ -62,6 +62,11 @@ module Backup
62
62
  # Default: :standard
63
63
  attr_accessor :storage_class
64
64
 
65
+ ##
66
+ # Additional options to pass along to fog.
67
+ # e.g. Fog::Storage.new({ :provider => 'AWS' }.merge(fog_options))
68
+ attr_accessor :fog_options
69
+
65
70
  def initialize(model, storage_id = nil)
66
71
  super
67
72
 
@@ -88,7 +93,8 @@ module Backup
88
93
  :storage_class => storage_class,
89
94
  :max_retries => max_retries,
90
95
  :retry_waitsec => retry_waitsec,
91
- :chunk_size => chunk_size
96
+ :chunk_size => chunk_size,
97
+ :fog_options => fog_options
92
98
  )
93
99
  end
94
100
 
@@ -28,6 +28,11 @@ module Backup
28
28
  # (LAN-based transfers to avoid charges and improve performance)
29
29
  attr_accessor :servicenet
30
30
 
31
+ ##
32
+ # Additional options to pass along to fog.
33
+ # e.g. Fog::Storage.new({ :provider => 'Rackspace' }.merge(fog_options))
34
+ attr_accessor :fog_options
35
+
31
36
  def initialize(syncer_id = nil)
32
37
  super
33
38
 
@@ -50,7 +55,8 @@ module Backup
50
55
  :retry_waitsec => retry_waitsec,
51
56
  # Syncer can not use SLOs.
52
57
  :segments_container => nil,
53
- :segment_size => 0
58
+ :segment_size => 0,
59
+ :fog_options => fog_options
54
60
  )
55
61
  end
56
62
 
@@ -40,6 +40,11 @@ module Backup
40
40
  # Default: :standard
41
41
  attr_accessor :storage_class
42
42
 
43
+ ##
44
+ # Additional options to pass along to fog.
45
+ # e.g. Fog::Storage.new({ :provider => 'AWS' }.merge(fog_options))
46
+ attr_accessor :fog_options
47
+
43
48
  def initialize(syncer_id = nil)
44
49
  super
45
50
 
@@ -62,7 +67,8 @@ module Backup
62
67
  :max_retries => max_retries,
63
68
  :retry_waitsec => retry_waitsec,
64
69
  # Syncer can not use multipart upload.
65
- :chunk_size => 0
70
+ :chunk_size => 0,
71
+ :fog_options => fog_options
66
72
  )
67
73
  end
68
74
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Backup
4
- VERSION = '3.8.0'
4
+ VERSION = '3.9.0'
5
5
  end
@@ -16,7 +16,7 @@
16
16
  # If you need to use a utility other than the one Backup detects,
17
17
  # or a utility can not be found in your $PATH.
18
18
  #
19
- # Backup::Utilities.configure do
19
+ # Utilities.configure do
20
20
  # tar '/usr/bin/gnutar'
21
21
  # redis_cli '/opt/redis/redis-cli'
22
22
  # end
@@ -27,7 +27,7 @@
27
27
  # Logging options may be set on the command line, but certain settings
28
28
  # may only be configured here.
29
29
  #
30
- # Backup::Logger.configure do
30
+ # Logger.configure do
31
31
  # console.quiet = true # Same as command line: --quiet
32
32
  # logfile.max_bytes = 2_000_000 # Default: 500_000
33
33
  # syslog.enabled = true # Same as command line: --syslog
@@ -45,15 +45,48 @@
45
45
  # Set default options to be applied to components in all models.
46
46
  # Options set within a model will override those set here.
47
47
  #
48
- # Backup::Storage::S3.defaults do |s3|
48
+ # Storage::S3.defaults do |s3|
49
49
  # s3.access_key_id = "my_access_key_id"
50
50
  # s3.secret_access_key = "my_secret_access_key"
51
51
  # end
52
52
  #
53
- # Backup::Encryptor::OpenSSL.defaults do |encryption|
54
- # encryption.password = "my_password"
55
- # encryption.base64 = true
56
- # encryption.salt = true
53
+ # Notifier::Mail.defaults do |mail|
54
+ # mail.from = 'sender@email.com'
55
+ # mail.to = 'receiver@email.com'
56
+ # mail.address = 'smtp.gmail.com'
57
+ # mail.port = 587
58
+ # mail.domain = 'your.host.name'
59
+ # mail.user_name = 'sender@email.com'
60
+ # mail.password = 'my_password'
61
+ # mail.authentication = 'plain'
62
+ # mail.encryption = :starttls
63
+ # end
64
+
65
+ ##
66
+ # Preconfigured Models
67
+ #
68
+ # Create custom models with preconfigured components.
69
+ # Components added within the model definition will
70
+ # +add to+ the preconfigured components.
71
+ #
72
+ # preconfigure 'MyModel' do
73
+ # archive :user_pictures do |archive|
74
+ # archive.add '~/pictures'
75
+ # end
76
+ #
77
+ # notify_by Mail do |mail|
78
+ # mail.to = 'admin@email.com'
79
+ # end
80
+ # end
81
+ #
82
+ # MyModel.new(:john_smith, 'John Smith Backup') do
83
+ # archive :user_music do |archive|
84
+ # archive.add '~/music'
85
+ # end
86
+ #
87
+ # notify_by Mail do |mail|
88
+ # mail.to = 'john.smith@email.com'
89
+ # end
57
90
  # end
58
91
 
59
92
 
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # $ backup perform -t <%= @options[:trigger] %> [-c <path_to_configuration_file>]
8
8
  #
9
- Backup::Model.new(:<%= @options[:trigger] %>, 'Description for <%= @options[:trigger] %>') do
9
+ Model.new(:<%= @options[:trigger] %>, 'Description for <%= @options[:trigger] %>') do
10
10
  <% if @options[:splitter] %>
11
11
  <%= Backup::Template.new.result("cli/splitter") %>
12
12
  <% end; if @options[:archives] %>
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.8.0
4
+ version: 3.9.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-10-24 00:00:00.000000000 Z
11
+ date: 2013-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder