backup 4.1.12 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/backup/notifier/base.rb +30 -0
- data/lib/backup/notifier/campfire.rb +1 -7
- data/lib/backup/notifier/datadog.rb +11 -20
- data/lib/backup/notifier/flowdock.rb +6 -5
- data/lib/backup/notifier/hipchat.rb +16 -7
- data/lib/backup/notifier/http_post.rb +2 -7
- data/lib/backup/notifier/mail.rb +1 -7
- data/lib/backup/notifier/nagios.rb +3 -8
- data/lib/backup/notifier/prowl.rb +8 -9
- data/lib/backup/notifier/pushover.rb +1 -7
- data/lib/backup/notifier/ses.rb +1 -7
- data/lib/backup/notifier/slack.rb +4 -10
- data/lib/backup/notifier/twitter.rb +1 -7
- data/lib/backup/notifier/zabbix.rb +1 -6
- data/lib/backup/packager.rb +8 -2
- data/lib/backup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b3395ec5399914784eeb39f638352a1ce486589
|
4
|
+
data.tar.gz: 7e8dfbc5aea5da8abed31b2dbf14d920cfcebb41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e9ac7c7b0ad9ef5d7b4d5ac4147206c4407cceba3704aa15f53b0c99fadfe4c8703e07daa16dd874f0c3c80e836f89d1db56204de60e5c607080c4f96c498cc
|
7
|
+
data.tar.gz: e64842958d8d39f15f739e76b554012389fbd7720710a0602cded468ae2c0829ed43039b0757bbec5d6f48a1e1b58db6aec625ad8954d956c44b8eec125f69ca
|
data/lib/backup/notifier/base.rb
CHANGED
@@ -36,6 +36,15 @@ module Backup
|
|
36
36
|
# Default: 30
|
37
37
|
attr_accessor :retry_waitsec
|
38
38
|
|
39
|
+
##
|
40
|
+
# Message to send. Depends on notifier implementation if this is used.
|
41
|
+
# Default: lambda returning:
|
42
|
+
# "#{ message } #{ model.label } (#{ model.trigger })"
|
43
|
+
#
|
44
|
+
# @yieldparam [model] Backup::Model
|
45
|
+
# @yieldparam [data] Hash containing `message` and `key` values.
|
46
|
+
attr_accessor :message
|
47
|
+
|
39
48
|
attr_reader :model
|
40
49
|
|
41
50
|
def initialize(model)
|
@@ -47,6 +56,9 @@ module Backup
|
|
47
56
|
@on_failure = true if on_failure.nil?
|
48
57
|
@max_retries ||= 10
|
49
58
|
@retry_waitsec ||= 30
|
59
|
+
@message ||= lambda do |model, data|
|
60
|
+
"[#{ data[:status][:message] }] #{ model.label } (#{ model.trigger })"
|
61
|
+
end
|
50
62
|
end
|
51
63
|
|
52
64
|
# This method is called from an ensure block in Model#perform! and must
|
@@ -93,6 +105,24 @@ module Backup
|
|
93
105
|
self.class.to_s.sub('Backup::', '')
|
94
106
|
end
|
95
107
|
|
108
|
+
##
|
109
|
+
# Return status data for message creation
|
110
|
+
def status_data_for(status)
|
111
|
+
{
|
112
|
+
:success => {
|
113
|
+
:message => 'Backup::Success',
|
114
|
+
:key => :success
|
115
|
+
},
|
116
|
+
:warning => {
|
117
|
+
:message => 'Backup::Warning',
|
118
|
+
:key => :warning
|
119
|
+
},
|
120
|
+
:failure => {
|
121
|
+
:message => 'Backup::Failure',
|
122
|
+
:key => :failure
|
123
|
+
}
|
124
|
+
}[status]
|
125
|
+
end
|
96
126
|
end
|
97
127
|
end
|
98
128
|
end
|
@@ -42,13 +42,7 @@ module Backup
|
|
42
42
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
43
43
|
#
|
44
44
|
def notify!(status)
|
45
|
-
|
46
|
-
when :success then '[Backup::Success]'
|
47
|
-
when :warning then '[Backup::Warning]'
|
48
|
-
when :failure then '[Backup::Failure]'
|
49
|
-
end
|
50
|
-
message = "#{ tag } #{ model.label } (#{ model.trigger })"
|
51
|
-
send_message(message)
|
45
|
+
send_message(message.call(model, :status => status_data_for(status)))
|
52
46
|
end
|
53
47
|
|
54
48
|
def send_message(message)
|
@@ -13,9 +13,10 @@ module Backup
|
|
13
13
|
# The title of the event
|
14
14
|
attr_accessor :title
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
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'
|
19
20
|
|
20
21
|
##
|
21
22
|
# The timestamp for the event
|
@@ -48,9 +49,7 @@ module Backup
|
|
48
49
|
def initialize(model, &block)
|
49
50
|
super
|
50
51
|
instance_eval(&block) if block_given?
|
51
|
-
|
52
|
-
@title ||= default_title
|
53
|
-
@text ||= default_text
|
52
|
+
@title ||= "Backup #{ model.label }"
|
54
53
|
end
|
55
54
|
|
56
55
|
private
|
@@ -73,7 +72,9 @@ module Backup
|
|
73
72
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
74
73
|
#
|
75
74
|
def notify!(status)
|
76
|
-
|
75
|
+
msg = message.call(model, :status => status_data_for(status))
|
76
|
+
|
77
|
+
hash = { alert_type: default_alert_type(status) }
|
77
78
|
hash.store(:msg_title, @title)
|
78
79
|
hash.store(:date_happened, @date_happened) if @date_happened
|
79
80
|
hash.store(:priority, @priority) if @priority
|
@@ -82,13 +83,13 @@ module Backup
|
|
82
83
|
hash.store(:aggregation_key, @aggregation_key) if @aggregation_key
|
83
84
|
hash.store(:source_type_name, @source_type_name) if @source_type_name
|
84
85
|
hash.store(:alert_type, @alert_type) if @alert_type
|
85
|
-
send_event(hash)
|
86
|
+
send_event(msg, hash)
|
86
87
|
end
|
87
88
|
|
88
89
|
# Dogapi::Client will raise an error if unsuccessful.
|
89
|
-
def send_event(hash)
|
90
|
+
def send_event(msg, hash)
|
90
91
|
client = Dogapi::Client.new(@api_key)
|
91
|
-
event = Dogapi::Event.new(
|
92
|
+
event = Dogapi::Event.new(msg, hash)
|
92
93
|
client.emit_event(event)
|
93
94
|
end
|
94
95
|
|
@@ -101,16 +102,6 @@ module Backup
|
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
|
-
# set default title
|
105
|
-
def default_title
|
106
|
-
"Backup #{ model.label }"
|
107
|
-
end
|
108
|
-
|
109
|
-
# set default text
|
110
|
-
def default_text
|
111
|
-
"Backup Notification for #{ model.label }"
|
112
|
-
end
|
113
|
-
|
114
105
|
end
|
115
106
|
end
|
116
107
|
end
|
@@ -61,15 +61,16 @@ module Backup
|
|
61
61
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
62
62
|
#
|
63
63
|
def notify!(status)
|
64
|
-
@tags
|
65
|
-
message
|
66
|
-
send_message(message)
|
64
|
+
@tags += default_tags(status)
|
65
|
+
send_message(message.call(model, status: status_data_for(status)))
|
67
66
|
end
|
68
67
|
|
69
68
|
# Flowdock::Client will raise an error if unsuccessful.
|
70
69
|
def send_message(msg)
|
71
|
-
client = Flowdock::Flow.new(
|
72
|
-
|
70
|
+
client = Flowdock::Flow.new(
|
71
|
+
:api_token => token, :source => source,
|
72
|
+
:from => {:name => from_name, :address => from_email }
|
73
|
+
)
|
73
74
|
|
74
75
|
client.push_to_team_inbox(:subject => subject,
|
75
76
|
:content => msg,
|
@@ -67,13 +67,9 @@ module Backup
|
|
67
67
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
68
68
|
#
|
69
69
|
def notify!(status)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
when :failure then ['[Backup::Failure]', failure_color]
|
74
|
-
end
|
75
|
-
message = "#{ tag } #{ model.label } (#{ model.trigger })"
|
76
|
-
send_message(message, color)
|
70
|
+
status_data = status_data_for(status)
|
71
|
+
msg = message.call(model, :status => status_data)
|
72
|
+
send_message(msg, status_data[:color])
|
77
73
|
end
|
78
74
|
|
79
75
|
# Hipchat::Client will raise an error if unsuccessful.
|
@@ -88,6 +84,19 @@ module Backup
|
|
88
84
|
Array(rooms_notified).map {|r| r.split(',').map(&:strip) }.flatten
|
89
85
|
end
|
90
86
|
|
87
|
+
def status_data_for(status)
|
88
|
+
data = super(status)
|
89
|
+
data[:color] = status_color_for(status)
|
90
|
+
data
|
91
|
+
end
|
92
|
+
|
93
|
+
def status_color_for(status)
|
94
|
+
{
|
95
|
+
:success => success_color,
|
96
|
+
:warning => warning_color,
|
97
|
+
:failure => failure_color
|
98
|
+
}[status]
|
99
|
+
end
|
91
100
|
end
|
92
101
|
end
|
93
102
|
end
|
@@ -95,18 +95,13 @@ module Backup
|
|
95
95
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
96
96
|
#
|
97
97
|
def notify!(status)
|
98
|
-
|
99
|
-
when :success then '[Backup::Success]'
|
100
|
-
when :failure then '[Backup::Failure]'
|
101
|
-
when :warning then '[Backup::Warning]'
|
102
|
-
end
|
103
|
-
message = "#{ tag } #{ model.label } (#{ model.trigger })"
|
98
|
+
msg = message.call(model, :status => status_data_for(status))
|
104
99
|
|
105
100
|
opts = {
|
106
101
|
:headers => { 'User-Agent' => "Backup/#{ VERSION }" }.
|
107
102
|
merge(headers).reject {|k,v| v.nil? }.
|
108
103
|
merge('Content-Type' => 'application/x-www-form-urlencoded'),
|
109
|
-
:body => URI.encode_www_form({ 'message' =>
|
104
|
+
:body => URI.encode_www_form({ 'message' => msg }.
|
110
105
|
merge(params).reject {|k,v| v.nil? }.
|
111
106
|
merge('status' => status.to_s)),
|
112
107
|
:expects => success_codes # raise error if unsuccessful
|
data/lib/backup/notifier/mail.rb
CHANGED
@@ -148,14 +148,8 @@ module Backup
|
|
148
148
|
# : backup log, if `on_failure` is `true`.
|
149
149
|
#
|
150
150
|
def notify!(status)
|
151
|
-
tag = case status
|
152
|
-
when :success then '[Backup::Success]'
|
153
|
-
when :warning then '[Backup::Warning]'
|
154
|
-
when :failure then '[Backup::Failure]'
|
155
|
-
end
|
156
|
-
|
157
151
|
email = new_email
|
158
|
-
email.subject =
|
152
|
+
email.subject = message.call(model, :status => status_data_for(status))
|
159
153
|
|
160
154
|
send_log = send_log_on.include?(status)
|
161
155
|
template = Backup::Template.new({ :model => model, :send_log => send_log })
|
@@ -14,8 +14,8 @@ module Backup
|
|
14
14
|
|
15
15
|
##
|
16
16
|
# Nagios nrpe configuration file.
|
17
|
-
attr_accessor :send_nsca_cfg
|
18
|
-
|
17
|
+
attr_accessor :send_nsca_cfg
|
18
|
+
|
19
19
|
##
|
20
20
|
# Name of the Nagios service for the backup check.
|
21
21
|
attr_accessor :service_name
|
@@ -55,12 +55,7 @@ module Backup
|
|
55
55
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
56
56
|
#
|
57
57
|
def notify!(status)
|
58
|
-
message
|
59
|
-
when :success then 'Completed Successfully'
|
60
|
-
when :warning then 'Completed Successfully (with Warnings)'
|
61
|
-
when :failure then 'Failed'
|
62
|
-
end
|
63
|
-
send_message("#{ message } in #{ model.duration }")
|
58
|
+
send_message(message.call(model, :status => status_data_for(status)))
|
64
59
|
end
|
65
60
|
|
66
61
|
def send_message(message)
|
@@ -16,6 +16,9 @@ module Backup
|
|
16
16
|
attr_accessor :api_key
|
17
17
|
|
18
18
|
def initialize(model, &block)
|
19
|
+
@message = lambda do |model, data|
|
20
|
+
"#{ model.label } (#{ model.trigger })"
|
21
|
+
end
|
19
22
|
super
|
20
23
|
instance_eval(&block) if block_given?
|
21
24
|
end
|
@@ -40,21 +43,17 @@ module Backup
|
|
40
43
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
41
44
|
#
|
42
45
|
def notify!(status)
|
43
|
-
|
44
|
-
when :success then '[Backup::Success]'
|
45
|
-
when :warning then '[Backup::Warning]'
|
46
|
-
when :failure then '[Backup::Failure]'
|
47
|
-
end
|
48
|
-
send_message(tag)
|
46
|
+
send_message(status)
|
49
47
|
end
|
50
48
|
|
51
|
-
def send_message(
|
49
|
+
def send_message(status)
|
52
50
|
uri = 'https://api.prowlapp.com/publicapi/add'
|
51
|
+
status_data = status_data_for(status)
|
53
52
|
data = {
|
54
53
|
:application => application,
|
55
54
|
:apikey => api_key,
|
56
|
-
:event => message,
|
57
|
-
:description =>
|
55
|
+
:event => status_data[:message],
|
56
|
+
:description => message.call(model, :status => status_data)
|
58
57
|
}
|
59
58
|
options = {
|
60
59
|
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
@@ -51,13 +51,7 @@ module Backup
|
|
51
51
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
52
52
|
#
|
53
53
|
def notify!(status)
|
54
|
-
|
55
|
-
when :success then '[Backup::Success]'
|
56
|
-
when :failure then '[Backup::Failure]'
|
57
|
-
when :warning then '[Backup::Warning]'
|
58
|
-
end
|
59
|
-
message = "#{ tag } #{ model.label } (#{ model.trigger })"
|
60
|
-
send_message(message)
|
54
|
+
send_message(message.call(model, :status => status_data_for(status)))
|
61
55
|
end
|
62
56
|
|
63
57
|
def send_message(message)
|
data/lib/backup/notifier/ses.rb
CHANGED
@@ -66,14 +66,8 @@ module Backup
|
|
66
66
|
# : backup log, if `on_failure` is `true`.
|
67
67
|
#
|
68
68
|
def notify!(status)
|
69
|
-
tag = case status
|
70
|
-
when :success then '[Backup::Success]'
|
71
|
-
when :warning then '[Backup::Warning]'
|
72
|
-
when :failure then '[Backup::Failure]'
|
73
|
-
end
|
74
|
-
|
75
69
|
email = ::Mail.new(:to => to, :from => from)
|
76
|
-
email.subject =
|
70
|
+
email.subject = message.call(model, :status => status_data_for(status))
|
77
71
|
|
78
72
|
send_log = send_log_on.include?(status)
|
79
73
|
template = Backup::Template.new({ :model => model, :send_log => send_log })
|
@@ -61,21 +61,15 @@ module Backup
|
|
61
61
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
62
62
|
#
|
63
63
|
def notify!(status)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
message = "#{ tag } #{ model.label } (#{ model.trigger })"
|
70
|
-
|
71
|
-
data = { :text => message }
|
64
|
+
data = {
|
65
|
+
:text => message.call(model, :status => status_data_for(status)),
|
66
|
+
:attachments => [attachment(status)]
|
67
|
+
}
|
72
68
|
[:channel, :username, :icon_emoji].each do |param|
|
73
69
|
val = send(param)
|
74
70
|
data.merge!(param => val) if val
|
75
71
|
end
|
76
72
|
|
77
|
-
data.merge!(:attachments => [attachment(status)])
|
78
|
-
|
79
73
|
options = {
|
80
74
|
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
81
75
|
:body => URI.encode_www_form(:payload => JSON.dump(data))
|
@@ -38,13 +38,7 @@ module Backup
|
|
38
38
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
39
39
|
#
|
40
40
|
def notify!(status)
|
41
|
-
|
42
|
-
when :success then '[Backup::Success]'
|
43
|
-
when :warning then '[Backup::Warning]'
|
44
|
-
when :failure then '[Backup::Failure]'
|
45
|
-
end
|
46
|
-
message = "#{ tag } #{ model.label } (#{ model.trigger }) (@ #{ model.time })"
|
47
|
-
send_message(message)
|
41
|
+
send_message(message.call(model, :status => status_data_for(status)))
|
48
42
|
end
|
49
43
|
|
50
44
|
# Twitter::Client will raise an error if unsuccessful.
|
@@ -45,12 +45,7 @@ module Backup
|
|
45
45
|
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
46
46
|
#
|
47
47
|
def notify!(status)
|
48
|
-
message
|
49
|
-
when :success then 'Completed Successfully'
|
50
|
-
when :warning then 'Completed Successfully (with Warnings)'
|
51
|
-
when :failure then 'Failed'
|
52
|
-
end
|
53
|
-
send_message("#{ message } in #{ model.duration }")
|
48
|
+
send_message(message.call(model, :status => status_data_for(status)))
|
54
49
|
end
|
55
50
|
|
56
51
|
def send_message(message)
|
data/lib/backup/packager.rb
CHANGED
@@ -42,8 +42,11 @@ module Backup
|
|
42
42
|
# The command's output will then be either piped to the Encryptor
|
43
43
|
# or the Splitter (if no Encryptor), or through `cat` into the final
|
44
44
|
# output file if neither are configured.
|
45
|
-
@pipeline
|
46
|
-
|
45
|
+
@pipeline.add(
|
46
|
+
"#{ utility(:tar) } -cf - " +
|
47
|
+
"-C '#{ Config.tmp_path }' '#{ @package.trigger }'",
|
48
|
+
tar_success_codes
|
49
|
+
)
|
47
50
|
|
48
51
|
##
|
49
52
|
# If an Encryptor was configured, it will be called first
|
@@ -96,6 +99,9 @@ module Backup
|
|
96
99
|
stack.shift
|
97
100
|
end
|
98
101
|
|
102
|
+
def tar_success_codes
|
103
|
+
gnu_tar? ? [0, 1] : [0]
|
104
|
+
end
|
99
105
|
end
|
100
106
|
end
|
101
107
|
end
|
data/lib/backup/version.rb
CHANGED
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: 4.
|
4
|
+
version: 4.2.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: 2015-09-
|
11
|
+
date: 2015-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: CFPropertyList
|