backup 4.1.10 → 4.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/backup.rb +1 -0
- data/lib/backup/config/dsl.rb +1 -1
- data/lib/backup/model.rb +26 -1
- data/lib/backup/notifier/command.rb +99 -0
- data/lib/backup/version.rb +1 -1
- data/templates/cli/notifiers/command +32 -0
- metadata +7 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 090ea9bc099efe67691fd99049e41b6d8d2ea39f
|
4
|
+
data.tar.gz: d80d17b22d496fc82c0428267245f4bf76b23f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd79088bb12aaf37821f6732240ce9f002acf5b85b4bbc4f7788d6aae6dd7930080215f21f2a2ac20e0ad162e06829fe99db984192a69ab05ec5c8a920feb599
|
7
|
+
data.tar.gz: f55230f51475db510b0218c8b059cf9d818f112b7d26d3fc8a1213f1835e6ad7694f641dc221edf321fb92f5d9ff2b018901ed544e0a33a7bec117d62583596d
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
Backup v4.x
|
2
2
|
===========
|
3
|
+
|
3
4
|
[](https://codeclimate.com/github/backup/backup)
|
4
5
|
[](https://travis-ci.org/backup/backup)
|
6
|
+
[](https://gitter.im/backup/backup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
7
|
|
6
8
|
Backup is a system utility for Linux and Mac OS X, distributed as a RubyGem, that allows you to easily perform backup
|
7
9
|
operations. It provides an elegant DSL in Ruby for _modeling_ your backups. Backup has built-in support for various
|
@@ -20,6 +22,6 @@ Released under the **MIT** [License](LICENSE.md).
|
|
20
22
|
[Release Notes]: http://backup.github.io/backup/v4/release-notes
|
21
23
|
[Documentation]: http://backup.github.io/backup/v4
|
22
24
|
[Issues]: https://github.com/backup/backup/issues
|
23
|
-
[Features]: https://github.com/
|
25
|
+
[Features]: https://github.com/backup/backup-features/issues
|
24
26
|
[Michael van Rooijen]: http://michaelvanrooijen.com
|
25
27
|
[@meskyanichi]: http://twitter.com/#!/meskyanichi
|
data/lib/backup.rb
CHANGED
@@ -116,6 +116,7 @@ module Backup
|
|
116
116
|
autoload :Zabbix, File.join(NOTIFIER_PATH, 'zabbix')
|
117
117
|
autoload :DataDog, File.join(NOTIFIER_PATH, 'datadog')
|
118
118
|
autoload :Ses, File.join(NOTIFIER_PATH, 'ses')
|
119
|
+
autoload :Command, File.join(NOTIFIER_PATH, 'command')
|
119
120
|
end
|
120
121
|
|
121
122
|
##
|
data/lib/backup/config/dsl.rb
CHANGED
@@ -43,7 +43,7 @@ module Backup
|
|
43
43
|
# Notifiers
|
44
44
|
['Mail', 'Twitter', 'Campfire', 'Prowl',
|
45
45
|
'Hipchat', 'PagerDuty', 'Pushover', 'HttpPost', 'Nagios',
|
46
|
-
'Slack', 'FlowDock', 'Zabbix', 'Ses', 'DataDog']
|
46
|
+
'Slack', 'FlowDock', 'Zabbix', 'Ses', 'DataDog', 'Command']
|
47
47
|
]
|
48
48
|
)
|
49
49
|
end
|
data/lib/backup/model.rb
CHANGED
@@ -303,7 +303,7 @@ module Backup
|
|
303
303
|
return [] unless databases.any? || archives.any?
|
304
304
|
|
305
305
|
[lambda { prepare! }, databases, archives,
|
306
|
-
lambda { package! },
|
306
|
+
lambda { package! }, lambda { store! }, lambda { clean! }]
|
307
307
|
end
|
308
308
|
|
309
309
|
##
|
@@ -325,6 +325,31 @@ module Backup
|
|
325
325
|
Cleaner.remove_packaging(self)
|
326
326
|
end
|
327
327
|
|
328
|
+
##
|
329
|
+
# Attempts to use all configured Storages, even if some of them result in exceptions.
|
330
|
+
# Returns true or raises first encountered exception.
|
331
|
+
def store!
|
332
|
+
storage_results = storages.map do |storage|
|
333
|
+
begin
|
334
|
+
storage.perform!
|
335
|
+
rescue => ex
|
336
|
+
ex
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
first_exception, *other_exceptions = storage_results.select { |result| result.is_a? Exception }
|
341
|
+
|
342
|
+
if first_exception
|
343
|
+
other_exceptions.each do |exception|
|
344
|
+
Logger.error exception.to_s
|
345
|
+
Logger.error exception.backtrace.join('\n')
|
346
|
+
end
|
347
|
+
raise first_exception
|
348
|
+
else
|
349
|
+
true
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
328
353
|
##
|
329
354
|
# Removes the final package file(s) once all configured Storages have run.
|
330
355
|
def clean!
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
module Notifier
|
5
|
+
class Command < Base
|
6
|
+
|
7
|
+
##
|
8
|
+
# Command to execute.
|
9
|
+
#
|
10
|
+
# Make sure it is accessible from your $PATH, or provide
|
11
|
+
# the absolute path to the command.
|
12
|
+
attr_accessor :command
|
13
|
+
|
14
|
+
##
|
15
|
+
# Arguments to pass to the command.
|
16
|
+
#
|
17
|
+
# Must be an array of strings or callable objects.
|
18
|
+
#
|
19
|
+
# Callables will be invoked with #call(model, status),
|
20
|
+
# and the return value used as the argument.
|
21
|
+
#
|
22
|
+
# In strings you can use the following placeholders:
|
23
|
+
#
|
24
|
+
# %l - Model label
|
25
|
+
# %t - Model trigger
|
26
|
+
# %s - Status (success/failure/warning)
|
27
|
+
# %v - Status verb (succeeded/failed/succeeded with warnings)
|
28
|
+
#
|
29
|
+
# All placeholders can be used with uppercase letters to capitalize
|
30
|
+
# the value.
|
31
|
+
#
|
32
|
+
# Defaults to ["%L %v"]
|
33
|
+
attr_accessor :args
|
34
|
+
|
35
|
+
def initialize(model, &block)
|
36
|
+
super
|
37
|
+
instance_eval(&block) if block_given?
|
38
|
+
|
39
|
+
@args ||= ["%L %v"]
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
##
|
45
|
+
# Notify the user of the backup operation results.
|
46
|
+
#
|
47
|
+
# `status` indicates one of the following:
|
48
|
+
#
|
49
|
+
# `:success`
|
50
|
+
# : The backup completed successfully.
|
51
|
+
# : Notification will be sent if `on_success` is `true`.
|
52
|
+
#
|
53
|
+
# `:warning`
|
54
|
+
# : The backup completed successfully, but warnings were logged.
|
55
|
+
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
56
|
+
#
|
57
|
+
# `:failure`
|
58
|
+
# : The backup operation failed.
|
59
|
+
# : Notification will be sent if `on_warning` or `on_success` is `true`.
|
60
|
+
#
|
61
|
+
def notify!(status)
|
62
|
+
IO.popen([@command] + args.map { |arg| format_arg(arg, status) })
|
63
|
+
end
|
64
|
+
|
65
|
+
def format_arg(arg, status)
|
66
|
+
if arg.respond_to?(:call)
|
67
|
+
arg.call(model, status)
|
68
|
+
else
|
69
|
+
arg.gsub(/%(\w)/) do |match|
|
70
|
+
ph = match[1]
|
71
|
+
val = case ph.downcase
|
72
|
+
when "l"
|
73
|
+
model.label
|
74
|
+
when "t"
|
75
|
+
model.trigger.to_s
|
76
|
+
when "v"
|
77
|
+
status_verb(status)
|
78
|
+
when "s"
|
79
|
+
status.to_s
|
80
|
+
end
|
81
|
+
val.capitalize! if ph == ph.upcase
|
82
|
+
val
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def status_verb(status)
|
88
|
+
case status
|
89
|
+
when :success
|
90
|
+
"succeeded"
|
91
|
+
when :failure
|
92
|
+
"failed"
|
93
|
+
when :warning
|
94
|
+
"succeeded with warnings"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/backup/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
##
|
2
|
+
# Command [Notifier]
|
3
|
+
#
|
4
|
+
notify_by Command do |cmd|
|
5
|
+
cmd.on_success = true
|
6
|
+
cmd.on_warning = true
|
7
|
+
cmd.on_failure = true
|
8
|
+
|
9
|
+
# Command to execute
|
10
|
+
cmd.command = 'notify-send'
|
11
|
+
|
12
|
+
# Arguments to pass to the command.
|
13
|
+
#
|
14
|
+
# Must be an array of strings or callable objects.
|
15
|
+
#
|
16
|
+
# Callables will be invoked with #call(model, status),
|
17
|
+
# and the return value used as the argument.
|
18
|
+
#
|
19
|
+
# In strings you can use the following placeholders:
|
20
|
+
#
|
21
|
+
# %l - Model label
|
22
|
+
# %t - Model trigger
|
23
|
+
# %s - Status (success/failure/warning)
|
24
|
+
# %v - Status verb (succeeded/failed/succeeded with warnings)
|
25
|
+
#
|
26
|
+
# All placeholders can be used with uppercase letters to capitalize
|
27
|
+
# the value.
|
28
|
+
#
|
29
|
+
# Defaults to ["%L %v"]
|
30
|
+
#
|
31
|
+
# cmd.args = ["Backup %L", "%V"]
|
32
|
+
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: 4.1.
|
4
|
+
version: 4.1.11
|
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-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: CFPropertyList
|
@@ -928,6 +928,7 @@ files:
|
|
928
928
|
- lib/backup/model.rb
|
929
929
|
- lib/backup/notifier/base.rb
|
930
930
|
- lib/backup/notifier/campfire.rb
|
931
|
+
- lib/backup/notifier/command.rb
|
931
932
|
- lib/backup/notifier/datadog.rb
|
932
933
|
- lib/backup/notifier/flowdock.rb
|
933
934
|
- lib/backup/notifier/hipchat.rb
|
@@ -985,6 +986,7 @@ files:
|
|
985
986
|
- templates/cli/model
|
986
987
|
- templates/cli/notifier/zabbix
|
987
988
|
- templates/cli/notifiers/campfire
|
989
|
+
- templates/cli/notifiers/command
|
988
990
|
- templates/cli/notifiers/datadog
|
989
991
|
- templates/cli/notifiers/flowdock
|
990
992
|
- templates/cli/notifiers/hipchat
|
@@ -1024,16 +1026,7 @@ homepage: https://github.com/backup/backup
|
|
1024
1026
|
licenses:
|
1025
1027
|
- MIT
|
1026
1028
|
metadata: {}
|
1027
|
-
post_install_message:
|
1028
|
-
|
1029
|
-
Thank you for installing Backup!
|
1030
|
-
|
1031
|
-
See the Release Notes for changes in this version:
|
1032
|
-
http://backup.github.io/backup/v4/release-notes
|
1033
|
-
|
1034
|
-
If you're upgrading from v3.x, be sure to read:
|
1035
|
-
http://backup.github.io/backup/v4/upgrading
|
1036
|
-
|
1029
|
+
post_install_message:
|
1037
1030
|
rdoc_options: []
|
1038
1031
|
require_paths:
|
1039
1032
|
- lib
|
@@ -1041,7 +1034,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1041
1034
|
requirements:
|
1042
1035
|
- - ">="
|
1043
1036
|
- !ruby/object:Gem::Version
|
1044
|
-
version:
|
1037
|
+
version: '2.0'
|
1045
1038
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1046
1039
|
requirements:
|
1047
1040
|
- - ">="
|
@@ -1049,7 +1042,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1049
1042
|
version: '0'
|
1050
1043
|
requirements: []
|
1051
1044
|
rubyforge_project:
|
1052
|
-
rubygems_version: 2.4.
|
1045
|
+
rubygems_version: 2.4.6
|
1053
1046
|
signing_key:
|
1054
1047
|
specification_version: 4
|
1055
1048
|
summary: Provides an elegant DSL in Ruby for performing backups on UNIX-like systems.
|