backup 4.4.1 → 5.0.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +19 -0
  3. data/README.md +13 -9
  4. data/bin/docker_test +24 -0
  5. data/lib/backup/archive.rb +31 -32
  6. data/lib/backup/binder.rb +2 -6
  7. data/lib/backup/cleaner.rb +14 -18
  8. data/lib/backup/cli.rb +104 -108
  9. data/lib/backup/cloud_io/base.rb +4 -7
  10. data/lib/backup/cloud_io/cloud_files.rb +60 -62
  11. data/lib/backup/cloud_io/s3.rb +69 -76
  12. data/lib/backup/compressor/base.rb +4 -7
  13. data/lib/backup/compressor/bzip2.rb +3 -7
  14. data/lib/backup/compressor/custom.rb +2 -6
  15. data/lib/backup/compressor/gzip.rb +16 -17
  16. data/lib/backup/config/dsl.rb +16 -17
  17. data/lib/backup/config/helpers.rb +10 -16
  18. data/lib/backup/config.rb +17 -18
  19. data/lib/backup/database/base.rb +22 -21
  20. data/lib/backup/database/mongodb.rb +36 -37
  21. data/lib/backup/database/mysql.rb +40 -41
  22. data/lib/backup/database/openldap.rb +8 -10
  23. data/lib/backup/database/postgresql.rb +29 -30
  24. data/lib/backup/database/redis.rb +27 -30
  25. data/lib/backup/database/riak.rb +15 -18
  26. data/lib/backup/database/sqlite.rb +4 -6
  27. data/lib/backup/encryptor/base.rb +2 -4
  28. data/lib/backup/encryptor/gpg.rb +49 -59
  29. data/lib/backup/encryptor/open_ssl.rb +11 -14
  30. data/lib/backup/errors.rb +7 -12
  31. data/lib/backup/logger/console.rb +5 -8
  32. data/lib/backup/logger/fog_adapter.rb +2 -6
  33. data/lib/backup/logger/logfile.rb +10 -12
  34. data/lib/backup/logger/syslog.rb +2 -4
  35. data/lib/backup/logger.rb +16 -18
  36. data/lib/backup/model.rb +33 -40
  37. data/lib/backup/notifier/base.rb +24 -26
  38. data/lib/backup/notifier/campfire.rb +9 -11
  39. data/lib/backup/notifier/command.rb +0 -3
  40. data/lib/backup/notifier/datadog.rb +9 -12
  41. data/lib/backup/notifier/flowdock.rb +13 -17
  42. data/lib/backup/notifier/hipchat.rb +11 -13
  43. data/lib/backup/notifier/http_post.rb +11 -14
  44. data/lib/backup/notifier/mail.rb +42 -59
  45. data/lib/backup/notifier/nagios.rb +5 -9
  46. data/lib/backup/notifier/pagerduty.rb +10 -12
  47. data/lib/backup/notifier/prowl.rb +15 -15
  48. data/lib/backup/notifier/pushover.rb +7 -10
  49. data/lib/backup/notifier/ses.rb +34 -16
  50. data/lib/backup/notifier/slack.rb +39 -40
  51. data/lib/backup/notifier/twitter.rb +2 -5
  52. data/lib/backup/notifier/zabbix.rb +11 -14
  53. data/lib/backup/package.rb +5 -9
  54. data/lib/backup/packager.rb +16 -17
  55. data/lib/backup/pipeline.rb +17 -21
  56. data/lib/backup/splitter.rb +8 -11
  57. data/lib/backup/storage/base.rb +5 -8
  58. data/lib/backup/storage/cloud_files.rb +21 -23
  59. data/lib/backup/storage/cycler.rb +10 -15
  60. data/lib/backup/storage/dropbox.rb +15 -21
  61. data/lib/backup/storage/ftp.rb +14 -10
  62. data/lib/backup/storage/local.rb +5 -8
  63. data/lib/backup/storage/qiniu.rb +8 -8
  64. data/lib/backup/storage/rsync.rb +24 -26
  65. data/lib/backup/storage/s3.rb +27 -28
  66. data/lib/backup/storage/scp.rb +10 -12
  67. data/lib/backup/storage/sftp.rb +10 -12
  68. data/lib/backup/syncer/base.rb +5 -8
  69. data/lib/backup/syncer/cloud/base.rb +27 -30
  70. data/lib/backup/syncer/cloud/cloud_files.rb +16 -18
  71. data/lib/backup/syncer/cloud/local_file.rb +5 -8
  72. data/lib/backup/syncer/cloud/s3.rb +23 -24
  73. data/lib/backup/syncer/rsync/base.rb +6 -10
  74. data/lib/backup/syncer/rsync/local.rb +1 -5
  75. data/lib/backup/syncer/rsync/pull.rb +6 -10
  76. data/lib/backup/syncer/rsync/push.rb +18 -22
  77. data/lib/backup/template.rb +9 -14
  78. data/lib/backup/utilities.rb +78 -69
  79. data/lib/backup/version.rb +1 -3
  80. data/lib/backup.rb +74 -78
  81. metadata +107 -676
data/lib/backup/model.rb CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Backup
4
2
  class Model
5
3
  class Error < Backup::Error; end
@@ -18,11 +16,11 @@ module Backup
18
16
  # Return an Array of Models matching the given +trigger+.
19
17
  def find_by_trigger(trigger)
20
18
  trigger = trigger.to_s
21
- if trigger.include?('*')
19
+ if trigger.include?("*")
22
20
  regex = /^#{ trigger.gsub('*', '(.*)') }$/
23
- all.select {|model| regex =~ model.trigger }
21
+ all.select { |model| regex =~ model.trigger }
24
22
  else
25
- all.select {|model| trigger == model.trigger }
23
+ all.select { |model| trigger == model.trigger }
26
24
  end
27
25
  end
28
26
 
@@ -128,7 +126,7 @@ module Backup
128
126
 
129
127
  # trigger all defined databases to generate their #dump_filename
130
128
  # so warnings may be logged if `backup perform --check` is used
131
- databases.each {|db| db.send(:dump_filename) }
129
+ databases.each { |db| db.send(:dump_filename) }
132
130
 
133
131
  Model.all << self
134
132
  end
@@ -142,15 +140,15 @@ module Backup
142
140
  ##
143
141
  # Adds an Database. Multiple Databases may be added to the model.
144
142
  def database(name, database_id = nil, &block)
145
- @databases << get_class_from_scope(Database, name).
146
- new(self, database_id, &block)
143
+ @databases << get_class_from_scope(Database, name)
144
+ .new(self, database_id, &block)
147
145
  end
148
146
 
149
147
  ##
150
148
  # Adds an Storage. Multiple Storages may be added to the model.
151
149
  def store_with(name, storage_id = nil, &block)
152
- @storages << get_class_from_scope(Storage, name).
153
- new(self, storage_id, &block)
150
+ @storages << get_class_from_scope(Storage, name)
151
+ .new(self, storage_id, &block)
154
152
  end
155
153
 
156
154
  ##
@@ -270,14 +268,11 @@ module Backup
270
268
  end
271
269
 
272
270
  syncers.each(&:perform!)
273
-
274
271
  rescue Interrupt
275
272
  @interrupted = true
276
273
  raise
277
-
278
274
  rescue Exception => err
279
275
  @exception = err
280
-
281
276
  ensure
282
277
  unless @interrupted
283
278
  set_exit_status
@@ -302,8 +297,8 @@ module Backup
302
297
  def procedures
303
298
  return [] unless databases.any? || archives.any?
304
299
 
305
- [lambda { prepare! }, databases, archives,
306
- lambda { package! }, lambda { store! }, lambda { clean! }]
300
+ [-> { prepare! }, databases, archives,
301
+ -> { package! }, -> { store! }, -> { clean! }]
307
302
  end
308
303
 
309
304
  ##
@@ -341,8 +336,8 @@ module Backup
341
336
 
342
337
  if first_exception
343
338
  other_exceptions.each do |exception|
344
- Logger.error exception.to_s
345
- Logger.error exception.backtrace.join('\n')
339
+ Logger.error exception.to_s
340
+ Logger.error exception.backtrace.join('\n')
346
341
  end
347
342
  raise first_exception
348
343
  else
@@ -375,8 +370,8 @@ module Backup
375
370
  #
376
371
  def get_class_from_scope(scope, name)
377
372
  klass = scope
378
- name = name.to_s.sub(/^Backup::Config::DSL::/, '')
379
- name.split('::').each do |chunk|
373
+ name = name.to_s.sub(/^Backup::Config::DSL::/, "")
374
+ name.split("::").each do |chunk|
380
375
  klass = klass.const_get(chunk)
381
376
  end
382
377
  klass
@@ -385,11 +380,12 @@ module Backup
385
380
  ##
386
381
  # Sets or updates the model's #exit_status.
387
382
  def set_exit_status
388
- @exit_status = if exception
389
- exception.is_a?(StandardError) ? 2 : 3
390
- else
391
- Logger.has_warnings? ? 1 : 0
392
- end
383
+ @exit_status =
384
+ if exception
385
+ exception.is_a?(StandardError) ? 2 : 3
386
+ else
387
+ Logger.has_warnings? ? 1 : 0
388
+ end
393
389
  end
394
390
 
395
391
  ##
@@ -401,14 +397,13 @@ module Backup
401
397
  def before_hook
402
398
  return unless before
403
399
 
404
- Logger.info 'Before Hook Starting...'
400
+ Logger.info "Before Hook Starting..."
405
401
  before.call
406
- Logger.info 'Before Hook Finished.'
407
-
402
+ Logger.info "Before Hook Finished."
408
403
  rescue Exception => err
409
404
  @before_hook_failed = true
410
405
  ex = err.is_a?(StandardError) ? Error : FatalError
411
- raise ex.wrap(err, 'Before Hook Failed!')
406
+ raise ex.wrap(err, "Before Hook Failed!")
412
407
  end
413
408
 
414
409
  ##
@@ -418,16 +413,15 @@ module Backup
418
413
  def after_hook
419
414
  return unless after && !@before_hook_failed
420
415
 
421
- Logger.info 'After Hook Starting...'
416
+ Logger.info "After Hook Starting..."
422
417
  after.call(exit_status)
423
- Logger.info 'After Hook Finished.'
418
+ Logger.info "After Hook Finished."
424
419
 
425
420
  set_exit_status # in case hook logged warnings
426
-
427
421
  rescue Exception => err
428
422
  fatal = !err.is_a?(StandardError)
429
423
  ex = fatal ? FatalError : Error
430
- Logger.error ex.wrap(err, 'After Hook Failed!')
424
+ Logger.error ex.wrap(err, "After Hook Failed!")
431
425
  # upgrade exit_status if needed
432
426
  (@exit_status = fatal ? 3 : 2) unless exit_status == 3
433
427
  end
@@ -440,24 +434,24 @@ module Backup
440
434
  def log!(action)
441
435
  case action
442
436
  when :started
443
- Logger.info "Performing Backup for '#{ label } (#{ trigger })'!\n" +
444
- "[ backup #{ VERSION } : #{ RUBY_DESCRIPTION } ]"
437
+ Logger.info "Performing Backup for '#{label} (#{trigger})'!\n" \
438
+ "[ backup #{VERSION} : #{RUBY_DESCRIPTION} ]"
445
439
 
446
440
  when :finished
447
441
  if exit_status > 1
448
442
  ex = exit_status == 2 ? Error : FatalError
449
- err = ex.wrap(exception, "Backup for #{ label } (#{ trigger }) Failed!")
443
+ err = ex.wrap(exception, "Backup for #{label} (#{trigger}) Failed!")
450
444
  Logger.error err
451
445
  Logger.error "\nBacktrace:\n\s\s" + err.backtrace.join("\n\s\s") + "\n\n"
452
446
 
453
447
  Cleaner.warnings(self)
454
448
  else
455
- msg = "Backup for '#{ label } (#{ trigger })' "
449
+ msg = "Backup for '#{label} (#{trigger})' "
456
450
  if exit_status == 1
457
- msg << "Completed Successfully (with Warnings) in #{ duration }"
451
+ msg << "Completed Successfully (with Warnings) in #{duration}"
458
452
  Logger.warn msg
459
453
  else
460
- msg << "Completed Successfully in #{ duration }"
454
+ msg << "Completed Successfully in #{duration}"
461
455
  Logger.info msg
462
456
  end
463
457
  end
@@ -472,8 +466,7 @@ module Backup
472
466
  remainder = duration - (hours * 3600)
473
467
  minutes = remainder / 60
474
468
  seconds = remainder - (minutes * 60)
475
- '%02d:%02d:%02d' % [hours, minutes, seconds]
469
+ sprintf "%02d:%02d:%02d", hours, minutes, seconds
476
470
  end
477
-
478
471
  end
479
472
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Backup
4
2
  module Notifier
5
3
  class Error < Backup::Error; end
@@ -56,8 +54,8 @@ module Backup
56
54
  @on_failure = true if on_failure.nil?
57
55
  @max_retries ||= 10
58
56
  @retry_waitsec ||= 30
59
- @message ||= lambda do |model, data|
60
- "[#{ data[:status][:message] }] #{ model.label } (#{ model.trigger })"
57
+ @message ||= lambda do |m, data|
58
+ "[#{data[:status][:message]}] #{m.label} (#{m.trigger})"
61
59
  end
62
60
  end
63
61
 
@@ -65,22 +63,22 @@ module Backup
65
63
  # not raise any exceptions. However, each Notifier's #notify! method
66
64
  # should raise an exception if the request fails so it may be retried.
67
65
  def perform!
68
- status = case model.exit_status
69
- when 0
70
- :success if notify_on_success?
71
- when 1
72
- :warning if notify_on_success? || notify_on_warning?
73
- else
74
- :failure if notify_on_failure?
75
- end
66
+ status =
67
+ case model.exit_status
68
+ when 0
69
+ :success if notify_on_success?
70
+ when 1
71
+ :warning if notify_on_success? || notify_on_warning?
72
+ else
73
+ :failure if notify_on_failure?
74
+ end
76
75
 
77
76
  if status
78
- Logger.info "Sending notification using #{ notifier_name }..."
77
+ Logger.info "Sending notification using #{notifier_name}..."
79
78
  with_retries { notify!(status) }
80
79
  end
81
-
82
80
  rescue Exception => err
83
- Logger.error Error.wrap(err, "#{ notifier_name } Failed!")
81
+ Logger.error Error.wrap(err, "#{notifier_name} Failed!")
84
82
  end
85
83
 
86
84
  private
@@ -93,7 +91,7 @@ module Backup
93
91
  retries += 1
94
92
  raise if retries > max_retries
95
93
 
96
- Logger.info Error.wrap(err, "Retry ##{ retries } of #{ max_retries }.")
94
+ Logger.info Error.wrap(err, "Retry ##{retries} of #{max_retries}.")
97
95
  sleep(retry_waitsec)
98
96
  retry
99
97
  end
@@ -102,24 +100,24 @@ module Backup
102
100
  ##
103
101
  # Return the notifier name, with Backup namespace removed
104
102
  def notifier_name
105
- self.class.to_s.sub('Backup::', '')
103
+ self.class.to_s.sub("Backup::", "")
106
104
  end
107
105
 
108
106
  ##
109
107
  # Return status data for message creation
110
108
  def status_data_for(status)
111
109
  {
112
- :success => {
113
- :message => 'Backup::Success',
114
- :key => :success
110
+ success: {
111
+ message: "Backup::Success",
112
+ key: :success
115
113
  },
116
- :warning => {
117
- :message => 'Backup::Warning',
118
- :key => :warning
114
+ warning: {
115
+ message: "Backup::Warning",
116
+ key: :warning
119
117
  },
120
- :failure => {
121
- :message => 'Backup::Failure',
122
- :key => :failure
118
+ failure: {
119
+ message: "Backup::Failure",
120
+ key: :failure
123
121
  }
124
122
  }[status]
125
123
  end
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
- require 'json'
1
+ require "json"
3
2
 
4
3
  module Backup
5
4
  module Notifier
6
5
  class Campfire < Base
7
-
8
6
  ##
9
7
  # Campfire api authentication token
10
8
  attr_accessor :api_token
@@ -42,22 +40,22 @@ module Backup
42
40
  # : Notification will be sent if `on_warning` or `on_success` is `true`.
43
41
  #
44
42
  def notify!(status)
45
- send_message(message.call(model, :status => status_data_for(status)))
43
+ send_message(message.call(model, status: status_data_for(status)))
46
44
  end
47
45
 
48
46
  def send_message(message)
49
- uri = "https://#{ subdomain }.campfirenow.com/room/#{ room_id }/speak.json"
47
+ uri = "https://#{subdomain}.campfirenow.com/room/#{room_id}/speak.json"
50
48
  options = {
51
- :headers => { 'Content-Type' => 'application/json' },
52
- :body => JSON.dump(
53
- { :message => { :body => message, :type => 'Textmessage' } }
49
+ headers: { "Content-Type" => "application/json" },
50
+ body: JSON.dump(
51
+ message: { body: message, type: "Textmessage" }
54
52
  )
55
53
  }
56
- options.merge!(:user => api_token, :password => 'x') # Basic Auth
57
- options.merge!(:expects => 201) # raise error if unsuccessful
54
+ options[:user] = api_token
55
+ options[:password] = "x" # Basic Auth
56
+ options[:expects] = 201 # raise error if unsuccessful
58
57
  Excon.post(uri, options)
59
58
  end
60
-
61
59
  end
62
60
  end
63
61
  end
@@ -1,9 +1,6 @@
1
- # encoding: utf-8
2
-
3
1
  module Backup
4
2
  module Notifier
5
3
  class Command < Base
6
-
7
4
  ##
8
5
  # Command to execute.
9
6
  #
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
- require 'dogapi'
1
+ require "dogapi"
3
2
 
4
3
  module Backup
5
4
  module Notifier
6
5
  class DataDog < Base
7
-
8
6
  ##
9
7
  # The DataDog API key
10
8
  attr_accessor :api_key
@@ -14,9 +12,9 @@ module Backup
14
12
  attr_accessor :title
15
13
 
16
14
  attr_deprecate :text,
17
- :version => '4.2',
18
- :message => 'Please use the `message` attribute. For more information '\
19
- 'see https://github.com/backup/backup/pull/698'
15
+ version: "4.2",
16
+ message: "Please use the `message` attribute. For more information "\
17
+ "see https://github.com/backup/backup/pull/698"
20
18
 
21
19
  ##
22
20
  # The timestamp for the event
@@ -49,7 +47,7 @@ module Backup
49
47
  def initialize(model, &block)
50
48
  super
51
49
  instance_eval(&block) if block_given?
52
- @title ||= "Backup #{ model.label }"
50
+ @title ||= "Backup #{model.label}"
53
51
  end
54
52
 
55
53
  private
@@ -72,7 +70,7 @@ module Backup
72
70
  # : Notification will be sent if `on_warning` or `on_success` is `true`.
73
71
  #
74
72
  def notify!(status)
75
- msg = message.call(model, :status => status_data_for(status))
73
+ msg = message.call(model, status: status_data_for(status))
76
74
 
77
75
  hash = { alert_type: default_alert_type(status) }
78
76
  hash.store(:msg_title, @title)
@@ -96,12 +94,11 @@ module Backup
96
94
  # set alert type
97
95
  def default_alert_type(status)
98
96
  case status
99
- when :success then 'success'
100
- when :warning then 'warning'
101
- when :failure then 'error'
97
+ when :success then "success"
98
+ when :warning then "warning"
99
+ when :failure then "error"
102
100
  end
103
101
  end
104
-
105
102
  end
106
103
  end
107
104
  end
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
- require 'flowdock'
1
+ require "flowdock"
3
2
 
4
3
  module Backup
5
4
  module Notifier
6
5
  class FlowDock < Base
7
-
8
6
  ##
9
7
  # The Flowdock API token
10
8
  attr_accessor :token
@@ -68,36 +66,34 @@ module Backup
68
66
  # Flowdock::Client will raise an error if unsuccessful.
69
67
  def send_message(msg)
70
68
  client = Flowdock::Flow.new(
71
- :api_token => token, :source => source,
72
- :from => {:name => from_name, :address => from_email }
69
+ api_token: token, source: source,
70
+ from: { name: from_name, address: from_email }
73
71
  )
74
72
 
75
- client.push_to_team_inbox(:subject => subject,
76
- :content => msg,
77
- :tags => tags,
78
- :link => link )
73
+ client.push_to_team_inbox(subject: subject,
74
+ content: msg,
75
+ tags: tags,
76
+ link: link)
79
77
  end
80
78
 
81
79
  # set related tags
82
80
  def default_tags(status)
83
81
  case status
84
- when :success then ['#BackupSuccess']
85
- when :warning then ['#BackupWarning']
86
- when :failure then ['#BackupFailure']
82
+ when :success then ["#BackupSuccess"]
83
+ when :warning then ["#BackupWarning"]
84
+ when :failure then ["#BackupFailure"]
87
85
  end
88
86
  end
89
87
 
90
-
91
- #set default source
88
+ # set default source
92
89
  def default_source
93
- "Backup #{ model.label }"
90
+ "Backup #{model.label}"
94
91
  end
95
92
 
96
93
  # set default subject
97
94
  def default_subject
98
- 'Backup Notification'
95
+ "Backup Notification"
99
96
  end
100
-
101
97
  end
102
98
  end
103
99
  end
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
- require 'hipchat'
1
+ require "hipchat"
3
2
 
4
3
  module Backup
5
4
  module Notifier
6
5
  class Hipchat < Base
7
-
8
6
  ##
9
7
  # The Hipchat API token
10
8
  attr_accessor :token
@@ -51,10 +49,10 @@ module Backup
51
49
 
52
50
  @notify_users ||= false
53
51
  @rooms_notified ||= []
54
- @success_color ||= 'yellow'
55
- @warning_color ||= 'yellow'
56
- @failure_color ||= 'yellow'
57
- @api_version ||= 'v1'
52
+ @success_color ||= "yellow"
53
+ @warning_color ||= "yellow"
54
+ @failure_color ||= "yellow"
55
+ @api_version ||= "v1"
58
56
  end
59
57
 
60
58
  private
@@ -78,7 +76,7 @@ module Backup
78
76
  #
79
77
  def notify!(status)
80
78
  status_data = status_data_for(status)
81
- msg = message.call(model, :status => status_data)
79
+ msg = message.call(model, status: status_data)
82
80
  send_message(msg, status_data[:color])
83
81
  end
84
82
 
@@ -92,12 +90,12 @@ module Backup
92
90
  def send_message(msg, color)
93
91
  client = HipChat::Client.new(token, client_options)
94
92
  rooms_to_notify.each do |room|
95
- client[room].send(from, msg, :color => color, :notify => notify_users)
93
+ client[room].send(from, msg, color: color, notify: notify_users)
96
94
  end
97
95
  end
98
96
 
99
97
  def rooms_to_notify
100
- Array(rooms_notified).map {|r| r.split(',').map(&:strip) }.flatten
98
+ Array(rooms_notified).map { |r| r.split(",").map(&:strip) }.flatten
101
99
  end
102
100
 
103
101
  def status_data_for(status)
@@ -108,9 +106,9 @@ module Backup
108
106
 
109
107
  def status_color_for(status)
110
108
  {
111
- :success => success_color,
112
- :warning => warning_color,
113
- :failure => failure_color
109
+ success: success_color,
110
+ warning: warning_color,
111
+ failure: failure_color
114
112
  }[status]
115
113
  end
116
114
  end
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
- require 'uri'
1
+ require "uri"
3
2
 
4
3
  module Backup
5
4
  module Notifier
6
5
  class HttpPost < Base
7
-
8
6
  ##
9
7
  # URI to post notification to.
10
8
  #
@@ -95,23 +93,22 @@ module Backup
95
93
  # : Notification will be sent if `on_warning` or `on_success` is `true`.
96
94
  #
97
95
  def notify!(status)
98
- msg = message.call(model, :status => status_data_for(status))
96
+ msg = message.call(model, status: status_data_for(status))
99
97
 
100
98
  opts = {
101
- :headers => { 'User-Agent' => "Backup/#{ VERSION }" }.
102
- merge(headers).reject {|k,v| v.nil? }.
103
- merge('Content-Type' => 'application/x-www-form-urlencoded'),
104
- :body => URI.encode_www_form({ 'message' => msg }.
105
- merge(params).reject {|k,v| v.nil? }.
106
- merge('status' => status.to_s)),
107
- :expects => success_codes # raise error if unsuccessful
99
+ headers: { "User-Agent" => "Backup/#{VERSION}" }
100
+ .merge(headers).reject { |_, value| value.nil? }
101
+ .merge("Content-Type" => "application/x-www-form-urlencoded"),
102
+ body: URI.encode_www_form({ "message" => msg }
103
+ .merge(params).reject { |_, value| value.nil? }
104
+ .merge("status" => status.to_s)),
105
+ expects: success_codes # raise error if unsuccessful
108
106
  }
109
- opts.merge!(:ssl_verify_peer => ssl_verify_peer) unless ssl_verify_peer.nil?
110
- opts.merge!(:ssl_ca_file => ssl_ca_file) if ssl_ca_file
107
+ opts[:ssl_verify_peer] = ssl_verify_peer unless ssl_verify_peer.nil?
108
+ opts[:ssl_ca_file] = ssl_ca_file if ssl_ca_file
111
109
 
112
110
  Excon.post(uri, opts)
113
111
  end
114
-
115
112
  end
116
113
  end
117
114
  end