backedup 5.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +19 -0
- data/README.md +33 -0
- data/bin/backedup +5 -0
- data/bin/docker_test +24 -0
- data/lib/backup/archive.rb +169 -0
- data/lib/backup/binder.rb +18 -0
- data/lib/backup/cleaner.rb +112 -0
- data/lib/backup/cli.rb +370 -0
- data/lib/backup/cloud_io/base.rb +38 -0
- data/lib/backup/cloud_io/cloud_files.rb +296 -0
- data/lib/backup/cloud_io/gcs.rb +121 -0
- data/lib/backup/cloud_io/s3.rb +253 -0
- data/lib/backup/cloud_io/swift.rb +96 -0
- data/lib/backup/compressor/base.rb +32 -0
- data/lib/backup/compressor/bzip2.rb +35 -0
- data/lib/backup/compressor/custom.rb +49 -0
- data/lib/backup/compressor/gzip.rb +73 -0
- data/lib/backup/compressor/pbzip2.rb +45 -0
- data/lib/backup/config/dsl.rb +102 -0
- data/lib/backup/config/helpers.rb +137 -0
- data/lib/backup/config.rb +118 -0
- data/lib/backup/database/base.rb +86 -0
- data/lib/backup/database/mongodb.rb +186 -0
- data/lib/backup/database/mysql.rb +191 -0
- data/lib/backup/database/openldap.rb +93 -0
- data/lib/backup/database/postgresql.rb +164 -0
- data/lib/backup/database/redis.rb +176 -0
- data/lib/backup/database/riak.rb +79 -0
- data/lib/backup/database/sqlite.rb +55 -0
- data/lib/backup/encryptor/base.rb +27 -0
- data/lib/backup/encryptor/gpg.rb +737 -0
- data/lib/backup/encryptor/open_ssl.rb +74 -0
- data/lib/backup/errors.rb +53 -0
- data/lib/backup/logger/console.rb +48 -0
- data/lib/backup/logger/fog_adapter.rb +25 -0
- data/lib/backup/logger/logfile.rb +131 -0
- data/lib/backup/logger/syslog.rb +114 -0
- data/lib/backup/logger.rb +197 -0
- data/lib/backup/model.rb +472 -0
- data/lib/backup/notifier/base.rb +126 -0
- data/lib/backup/notifier/campfire.rb +61 -0
- data/lib/backup/notifier/command.rb +99 -0
- data/lib/backup/notifier/datadog.rb +104 -0
- data/lib/backup/notifier/flowdock.rb +99 -0
- data/lib/backup/notifier/hipchat.rb +116 -0
- data/lib/backup/notifier/http_post.rb +114 -0
- data/lib/backup/notifier/mail.rb +232 -0
- data/lib/backup/notifier/nagios.rb +65 -0
- data/lib/backup/notifier/pagerduty.rb +79 -0
- data/lib/backup/notifier/prowl.rb +68 -0
- data/lib/backup/notifier/pushover.rb +71 -0
- data/lib/backup/notifier/ses.rb +123 -0
- data/lib/backup/notifier/slack.rb +147 -0
- data/lib/backup/notifier/twitter.rb +55 -0
- data/lib/backup/notifier/zabbix.rb +60 -0
- data/lib/backup/package.rb +51 -0
- data/lib/backup/packager.rb +106 -0
- data/lib/backup/pipeline.rb +120 -0
- data/lib/backup/splitter.rb +73 -0
- data/lib/backup/storage/base.rb +66 -0
- data/lib/backup/storage/cloud_files.rb +156 -0
- data/lib/backup/storage/cycler.rb +70 -0
- data/lib/backup/storage/dropbox.rb +206 -0
- data/lib/backup/storage/ftp.rb +116 -0
- data/lib/backup/storage/gcs.rb +93 -0
- data/lib/backup/storage/local.rb +61 -0
- data/lib/backup/storage/qiniu.rb +65 -0
- data/lib/backup/storage/rsync.rb +246 -0
- data/lib/backup/storage/s3.rb +155 -0
- data/lib/backup/storage/scp.rb +65 -0
- data/lib/backup/storage/sftp.rb +80 -0
- data/lib/backup/storage/swift.rb +124 -0
- data/lib/backup/storage/webdav.rb +102 -0
- data/lib/backup/syncer/base.rb +67 -0
- data/lib/backup/syncer/cloud/base.rb +176 -0
- data/lib/backup/syncer/cloud/cloud_files.rb +81 -0
- data/lib/backup/syncer/cloud/local_file.rb +97 -0
- data/lib/backup/syncer/cloud/s3.rb +109 -0
- data/lib/backup/syncer/rsync/base.rb +50 -0
- data/lib/backup/syncer/rsync/local.rb +27 -0
- data/lib/backup/syncer/rsync/pull.rb +47 -0
- data/lib/backup/syncer/rsync/push.rb +201 -0
- data/lib/backup/template.rb +41 -0
- data/lib/backup/utilities.rb +234 -0
- data/lib/backup/version.rb +3 -0
- data/lib/backup.rb +145 -0
- data/templates/cli/archive +28 -0
- data/templates/cli/compressor/bzip2 +4 -0
- data/templates/cli/compressor/custom +7 -0
- data/templates/cli/compressor/gzip +4 -0
- data/templates/cli/config +123 -0
- data/templates/cli/databases/mongodb +15 -0
- data/templates/cli/databases/mysql +18 -0
- data/templates/cli/databases/openldap +24 -0
- data/templates/cli/databases/postgresql +16 -0
- data/templates/cli/databases/redis +16 -0
- data/templates/cli/databases/riak +17 -0
- data/templates/cli/databases/sqlite +11 -0
- data/templates/cli/encryptor/gpg +27 -0
- data/templates/cli/encryptor/openssl +9 -0
- data/templates/cli/model +26 -0
- data/templates/cli/notifier/zabbix +15 -0
- data/templates/cli/notifiers/campfire +12 -0
- data/templates/cli/notifiers/command +32 -0
- data/templates/cli/notifiers/datadog +57 -0
- data/templates/cli/notifiers/flowdock +16 -0
- data/templates/cli/notifiers/hipchat +16 -0
- data/templates/cli/notifiers/http_post +32 -0
- data/templates/cli/notifiers/mail +24 -0
- data/templates/cli/notifiers/nagios +13 -0
- data/templates/cli/notifiers/pagerduty +12 -0
- data/templates/cli/notifiers/prowl +11 -0
- data/templates/cli/notifiers/pushover +11 -0
- data/templates/cli/notifiers/ses +15 -0
- data/templates/cli/notifiers/slack +22 -0
- data/templates/cli/notifiers/twitter +13 -0
- data/templates/cli/splitter +7 -0
- data/templates/cli/storages/cloud_files +11 -0
- data/templates/cli/storages/dropbox +20 -0
- data/templates/cli/storages/ftp +13 -0
- data/templates/cli/storages/gcs +8 -0
- data/templates/cli/storages/local +8 -0
- data/templates/cli/storages/qiniu +12 -0
- data/templates/cli/storages/rsync +17 -0
- data/templates/cli/storages/s3 +16 -0
- data/templates/cli/storages/scp +15 -0
- data/templates/cli/storages/sftp +15 -0
- data/templates/cli/storages/swift +19 -0
- data/templates/cli/storages/webdav +13 -0
- data/templates/cli/syncers/cloud_files +22 -0
- data/templates/cli/syncers/rsync_local +20 -0
- data/templates/cli/syncers/rsync_pull +28 -0
- data/templates/cli/syncers/rsync_push +28 -0
- data/templates/cli/syncers/s3 +27 -0
- data/templates/general/links +3 -0
- data/templates/general/version.erb +2 -0
- data/templates/notifier/mail/failure.erb +16 -0
- data/templates/notifier/mail/success.erb +16 -0
- data/templates/notifier/mail/warning.erb +16 -0
- data/templates/storage/dropbox/authorization_url.erb +6 -0
- data/templates/storage/dropbox/authorized.erb +4 -0
- data/templates/storage/dropbox/cache_file_written.erb +10 -0
- metadata +1255 -0
@@ -0,0 +1,234 @@
|
|
1
|
+
module Backup
|
2
|
+
module Utilities
|
3
|
+
class Error < Backup::Error; end
|
4
|
+
|
5
|
+
UTILITIES_NAMES = %w[
|
6
|
+
tar cat split sudo chown hostname
|
7
|
+
gzip bzip2 pbzip2
|
8
|
+
mongo mongodump mysqldump innobackupex
|
9
|
+
pg_dump pg_dumpall redis-cli riak-admin
|
10
|
+
gpg openssl
|
11
|
+
rsync ssh
|
12
|
+
sendmail exim
|
13
|
+
send_nsca
|
14
|
+
zabbix_sender
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
class DSL
|
19
|
+
def initialize(utils)
|
20
|
+
@utilities = utils
|
21
|
+
end
|
22
|
+
|
23
|
+
# Helper methods to allow users to set the path for all utilities in the
|
24
|
+
# .configure block.
|
25
|
+
#
|
26
|
+
# Utility names with dashes (`redis-cli`) will be set using method calls
|
27
|
+
# with an underscore (`redis_cli`).
|
28
|
+
UTILITIES_NAMES.each do |util_name|
|
29
|
+
define_method util_name.tr("-", "_") do |raw_path|
|
30
|
+
path = File.expand_path(raw_path)
|
31
|
+
|
32
|
+
unless File.executable?(path)
|
33
|
+
raise Utilities::Error, <<-EOS
|
34
|
+
The path given for '#{util_name}' was not found or not executable.
|
35
|
+
Path was: #{path}
|
36
|
+
EOS
|
37
|
+
end
|
38
|
+
|
39
|
+
@utilities.utilities[util_name] = path
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Allow users to set the +tar+ distribution if needed. (:gnu or :bsd)
|
44
|
+
def tar_dist(val)
|
45
|
+
Utilities.tar_dist(val)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class << self
|
50
|
+
##
|
51
|
+
# Configure the path to system utilities used by Backup.
|
52
|
+
#
|
53
|
+
# Backup will attempt to locate any required system utilities using a
|
54
|
+
# +which+ command call. If a utility can not be found, or you need to
|
55
|
+
# specify an alternate path for a utility, you may do so in your
|
56
|
+
# +config.rb+ file using this method.
|
57
|
+
#
|
58
|
+
# Backup supports both GNU and BSD utilities.
|
59
|
+
# While Backup uses these utilities in a manner compatible with either
|
60
|
+
# version, the +tar+ utility requires some special handling with respect
|
61
|
+
# to +Archive+s. Backup will attempt to detect if the +tar+ command
|
62
|
+
# found (or set here) is GNU or BSD. If for some reason this fails,
|
63
|
+
# this may be set using the +tar_dist+ command shown below.
|
64
|
+
#
|
65
|
+
# Backup::Utilities.configure do
|
66
|
+
# # General Utilites
|
67
|
+
# tar '/path/to/tar'
|
68
|
+
# tar_dist :gnu # or :bsd
|
69
|
+
# cat '/path/to/cat'
|
70
|
+
# split '/path/to/split'
|
71
|
+
# sudo '/path/to/sudo'
|
72
|
+
# chown '/path/to/chown'
|
73
|
+
# hostname '/path/to/hostname'
|
74
|
+
#
|
75
|
+
# # Compressors
|
76
|
+
# gzip '/path/to/gzip'
|
77
|
+
# bzip2 '/path/to/bzip2'
|
78
|
+
# pbzip2 '/path/to/pbzip2'
|
79
|
+
#
|
80
|
+
# # Database Utilities
|
81
|
+
# mongo '/path/to/mongo'
|
82
|
+
# mongodump '/path/to/mongodump'
|
83
|
+
# mysqldump '/path/to/mysqldump'
|
84
|
+
# pg_dump '/path/to/pg_dump'
|
85
|
+
# pg_dumpall '/path/to/pg_dumpall'
|
86
|
+
# redis_cli '/path/to/redis-cli'
|
87
|
+
# riak_admin '/path/to/riak-admin'
|
88
|
+
#
|
89
|
+
# # Encryptors
|
90
|
+
# gpg '/path/to/gpg'
|
91
|
+
# openssl '/path/to/openssl'
|
92
|
+
#
|
93
|
+
# # Syncer and Storage
|
94
|
+
# rsync '/path/to/rsync'
|
95
|
+
# ssh '/path/to/ssh'
|
96
|
+
#
|
97
|
+
# # Notifiers
|
98
|
+
# sendmail '/path/to/sendmail'
|
99
|
+
# exim '/path/to/exim'
|
100
|
+
# send_nsca '/path/to/send_nsca'
|
101
|
+
# zabbix_sender '/path/to/zabbix_sender'
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# These paths may be set using absolute paths, or relative to the
|
105
|
+
# working directory when Backup is run.
|
106
|
+
def configure(&block)
|
107
|
+
DSL.new(self).instance_eval(&block)
|
108
|
+
end
|
109
|
+
|
110
|
+
def tar_dist(val)
|
111
|
+
# the acceptance tests need to be able to reset this to nil
|
112
|
+
@gnu_tar = val.nil? ? nil : val == :gnu
|
113
|
+
end
|
114
|
+
|
115
|
+
def gnu_tar?
|
116
|
+
return @gnu_tar unless @gnu_tar.nil?
|
117
|
+
@gnu_tar = !!run("#{utility(:tar)} --version").match(/GNU/)
|
118
|
+
end
|
119
|
+
|
120
|
+
def utilities
|
121
|
+
@utilities ||= {}
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
##
|
127
|
+
# Returns the full path to the specified utility.
|
128
|
+
# Raises an error if utility can not be found in the system's $PATH
|
129
|
+
def utility(name)
|
130
|
+
name = name.to_s.strip
|
131
|
+
raise Error, "Utility Name Empty" if name.empty?
|
132
|
+
|
133
|
+
utilities[name] ||= `which '#{name}' 2>/dev/null`.chomp
|
134
|
+
raise Error, <<-EOS if utilities[name].empty?
|
135
|
+
Could not locate '#{name}'.
|
136
|
+
Make sure the specified utility is installed
|
137
|
+
and available in your system's $PATH, or specify it's location
|
138
|
+
in your 'config.rb' file using Backup::Utilities.configure
|
139
|
+
EOS
|
140
|
+
|
141
|
+
utilities[name].dup
|
142
|
+
end
|
143
|
+
|
144
|
+
##
|
145
|
+
# Returns the name of the command name from the given command line.
|
146
|
+
# This is only used to simplify log messages.
|
147
|
+
def command_name(command)
|
148
|
+
parts = []
|
149
|
+
command = command.split(" ")
|
150
|
+
command.shift while command[0].to_s.include?("=")
|
151
|
+
parts << command.shift.split("/")[-1]
|
152
|
+
if parts[0] == "sudo"
|
153
|
+
until command.empty?
|
154
|
+
part = command.shift
|
155
|
+
if part.include?("/")
|
156
|
+
parts << part.split("/")[-1]
|
157
|
+
break
|
158
|
+
else
|
159
|
+
parts << part
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
parts.join(" ")
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# Runs a system command
|
168
|
+
#
|
169
|
+
# All messages generated by the command will be logged.
|
170
|
+
# Messages on STDERR will be logged as warnings.
|
171
|
+
#
|
172
|
+
# If the command fails to execute, or returns a non-zero exit status
|
173
|
+
# an Error will be raised.
|
174
|
+
#
|
175
|
+
# Returns STDOUT
|
176
|
+
def run(command)
|
177
|
+
name = command_name(command)
|
178
|
+
Logger.info "Running system utility '#{name}'..."
|
179
|
+
|
180
|
+
begin
|
181
|
+
out = ""
|
182
|
+
err = ""
|
183
|
+
ps = Open4.popen4(command) do |_pid, stdin, stdout, stderr|
|
184
|
+
stdin.close
|
185
|
+
out = stdout.read.strip
|
186
|
+
err = stderr.read.strip
|
187
|
+
end
|
188
|
+
rescue Exception => e
|
189
|
+
raise Error.wrap(e, "Failed to execute '#{name}'")
|
190
|
+
end
|
191
|
+
|
192
|
+
unless ps.success?
|
193
|
+
raise Error, <<-EOS
|
194
|
+
'#{name}' failed with exit status: #{ps.exitstatus}
|
195
|
+
STDOUT Messages: #{out.empty? ? "None" : "\n#{out}"}
|
196
|
+
STDERR Messages: #{err.empty? ? "None" : "\n#{err}"}
|
197
|
+
EOS
|
198
|
+
end
|
199
|
+
|
200
|
+
unless out.empty?
|
201
|
+
Logger.info(out.lines.map { |line| "#{name}:STDOUT: #{line}" }.join)
|
202
|
+
end
|
203
|
+
|
204
|
+
unless err.empty?
|
205
|
+
Logger.warn(err.lines.map { |line| "#{name}:STDERR: #{line}" }.join)
|
206
|
+
end
|
207
|
+
|
208
|
+
out
|
209
|
+
end
|
210
|
+
|
211
|
+
def reset!
|
212
|
+
utilities.clear
|
213
|
+
@gnu_tar = nil
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
# Allows these utility methods to be included in other classes,
|
218
|
+
# while allowing them to be stubbed in spec_helper for all specs.
|
219
|
+
module Helpers
|
220
|
+
[:utility, :command_name, :run].each do |name|
|
221
|
+
define_method name do |arg|
|
222
|
+
Utilities.send(name, arg)
|
223
|
+
end
|
224
|
+
private name
|
225
|
+
end
|
226
|
+
|
227
|
+
private
|
228
|
+
|
229
|
+
def gnu_tar?
|
230
|
+
Utilities.gnu_tar?
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
data/lib/backup.rb
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
# Load Ruby Core Libraries
|
2
|
+
require "time"
|
3
|
+
require "fileutils"
|
4
|
+
require "tempfile"
|
5
|
+
require "syslog"
|
6
|
+
require "yaml"
|
7
|
+
require "etc"
|
8
|
+
require "forwardable"
|
9
|
+
require "thread"
|
10
|
+
|
11
|
+
require "open4"
|
12
|
+
require "thor"
|
13
|
+
require "shellwords"
|
14
|
+
|
15
|
+
require "excon"
|
16
|
+
# Include response.inspect in error messages.
|
17
|
+
Excon.defaults[:debug_response] = true
|
18
|
+
# Excon should not retry failed requests. We handle that.
|
19
|
+
Excon.defaults[:middlewares].delete(Excon::Middleware::Idempotent)
|
20
|
+
|
21
|
+
##
|
22
|
+
# The Backup Ruby Gem
|
23
|
+
module Backup
|
24
|
+
##
|
25
|
+
# Backup's internal paths
|
26
|
+
LIBRARY_PATH = File.join(File.dirname(__FILE__), "backup")
|
27
|
+
STORAGE_PATH = File.join(LIBRARY_PATH, "storage")
|
28
|
+
SYNCER_PATH = File.join(LIBRARY_PATH, "syncer")
|
29
|
+
DATABASE_PATH = File.join(LIBRARY_PATH, "database")
|
30
|
+
COMPRESSOR_PATH = File.join(LIBRARY_PATH, "compressor")
|
31
|
+
ENCRYPTOR_PATH = File.join(LIBRARY_PATH, "encryptor")
|
32
|
+
NOTIFIER_PATH = File.join(LIBRARY_PATH, "notifier")
|
33
|
+
TEMPLATE_PATH = File.expand_path("../../templates", __FILE__)
|
34
|
+
|
35
|
+
##
|
36
|
+
# Autoload Backup storage files
|
37
|
+
module Storage
|
38
|
+
autoload :Base, File.join(STORAGE_PATH, "base")
|
39
|
+
autoload :Cycler, File.join(STORAGE_PATH, "cycler")
|
40
|
+
autoload :S3, File.join(STORAGE_PATH, "s3")
|
41
|
+
autoload :Swift, File.join(STORAGE_PATH, "swift")
|
42
|
+
autoload :GCS, File.join(STORAGE_PATH, "gcs")
|
43
|
+
autoload :CloudFiles, File.join(STORAGE_PATH, "cloud_files")
|
44
|
+
autoload :Ninefold, File.join(STORAGE_PATH, "ninefold")
|
45
|
+
autoload :Dropbox, File.join(STORAGE_PATH, "dropbox")
|
46
|
+
autoload :FTP, File.join(STORAGE_PATH, "ftp")
|
47
|
+
autoload :SFTP, File.join(STORAGE_PATH, "sftp")
|
48
|
+
autoload :SCP, File.join(STORAGE_PATH, "scp")
|
49
|
+
autoload :RSync, File.join(STORAGE_PATH, "rsync")
|
50
|
+
autoload :Local, File.join(STORAGE_PATH, "local")
|
51
|
+
autoload :Qiniu, File.join(STORAGE_PATH, "qiniu")
|
52
|
+
autoload :Webdav, File.join(STORAGE_PATH, 'webdav')
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Autoload Backup syncer files
|
57
|
+
module Syncer
|
58
|
+
autoload :Base, File.join(SYNCER_PATH, "base")
|
59
|
+
module Cloud
|
60
|
+
autoload :Base, File.join(SYNCER_PATH, "cloud", "base")
|
61
|
+
autoload :LocalFile, File.join(SYNCER_PATH, "cloud", "local_file")
|
62
|
+
autoload :CloudFiles, File.join(SYNCER_PATH, "cloud", "cloud_files")
|
63
|
+
autoload :S3, File.join(SYNCER_PATH, "cloud", "s3")
|
64
|
+
autoload :GCS, File.join(SYNCER_PATH, "cloud", "gcs")
|
65
|
+
end
|
66
|
+
module RSync
|
67
|
+
autoload :Base, File.join(SYNCER_PATH, "rsync", "base")
|
68
|
+
autoload :Local, File.join(SYNCER_PATH, "rsync", "local")
|
69
|
+
autoload :Push, File.join(SYNCER_PATH, "rsync", "push")
|
70
|
+
autoload :Pull, File.join(SYNCER_PATH, "rsync", "pull")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Autoload Backup database files
|
76
|
+
module Database
|
77
|
+
autoload :Base, File.join(DATABASE_PATH, "base")
|
78
|
+
autoload :MySQL, File.join(DATABASE_PATH, "mysql")
|
79
|
+
autoload :PostgreSQL, File.join(DATABASE_PATH, "postgresql")
|
80
|
+
autoload :MongoDB, File.join(DATABASE_PATH, "mongodb")
|
81
|
+
autoload :Redis, File.join(DATABASE_PATH, "redis")
|
82
|
+
autoload :Riak, File.join(DATABASE_PATH, "riak")
|
83
|
+
autoload :OpenLDAP, File.join(DATABASE_PATH, "openldap")
|
84
|
+
autoload :SQLite, File.join(DATABASE_PATH, "sqlite")
|
85
|
+
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# Autoload compressor files
|
89
|
+
module Compressor
|
90
|
+
autoload :Base, File.join(COMPRESSOR_PATH, "base")
|
91
|
+
autoload :Gzip, File.join(COMPRESSOR_PATH, "gzip")
|
92
|
+
autoload :Bzip2, File.join(COMPRESSOR_PATH, "bzip2")
|
93
|
+
autoload :PBzip2, File.join(COMPRESSOR_PATH, "pbzip2")
|
94
|
+
autoload :Custom, File.join(COMPRESSOR_PATH, "custom")
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Autoload encryptor files
|
99
|
+
module Encryptor
|
100
|
+
autoload :Base, File.join(ENCRYPTOR_PATH, "base")
|
101
|
+
autoload :OpenSSL, File.join(ENCRYPTOR_PATH, "open_ssl")
|
102
|
+
autoload :GPG, File.join(ENCRYPTOR_PATH, "gpg")
|
103
|
+
end
|
104
|
+
|
105
|
+
##
|
106
|
+
# Autoload notification files
|
107
|
+
module Notifier
|
108
|
+
autoload :Base, File.join(NOTIFIER_PATH, "base")
|
109
|
+
autoload :Mail, File.join(NOTIFIER_PATH, "mail")
|
110
|
+
autoload :Twitter, File.join(NOTIFIER_PATH, "twitter")
|
111
|
+
autoload :Campfire, File.join(NOTIFIER_PATH, "campfire")
|
112
|
+
autoload :Prowl, File.join(NOTIFIER_PATH, "prowl")
|
113
|
+
autoload :Hipchat, File.join(NOTIFIER_PATH, "hipchat")
|
114
|
+
autoload :PagerDuty, File.join(NOTIFIER_PATH, "pagerduty")
|
115
|
+
autoload :Pushover, File.join(NOTIFIER_PATH, "pushover")
|
116
|
+
autoload :Slack, File.join(NOTIFIER_PATH, "slack")
|
117
|
+
autoload :HttpPost, File.join(NOTIFIER_PATH, "http_post")
|
118
|
+
autoload :Nagios, File.join(NOTIFIER_PATH, "nagios")
|
119
|
+
autoload :FlowDock, File.join(NOTIFIER_PATH, "flowdock")
|
120
|
+
autoload :Zabbix, File.join(NOTIFIER_PATH, "zabbix")
|
121
|
+
autoload :DataDog, File.join(NOTIFIER_PATH, "datadog")
|
122
|
+
autoload :Ses, File.join(NOTIFIER_PATH, "ses")
|
123
|
+
autoload :Command, File.join(NOTIFIER_PATH, "command")
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Require Backup base files
|
128
|
+
%w[
|
129
|
+
errors
|
130
|
+
logger
|
131
|
+
utilities
|
132
|
+
archive
|
133
|
+
binder
|
134
|
+
cleaner
|
135
|
+
model
|
136
|
+
config
|
137
|
+
cli
|
138
|
+
package
|
139
|
+
packager
|
140
|
+
pipeline
|
141
|
+
splitter
|
142
|
+
template
|
143
|
+
version
|
144
|
+
].each { |lib| require File.join(LIBRARY_PATH, lib) }
|
145
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
##
|
2
|
+
# Archive [Archive]
|
3
|
+
#
|
4
|
+
# Adding a file or directory (including sub-directories):
|
5
|
+
# archive.add "/path/to/a/file.rb"
|
6
|
+
# archive.add "/path/to/a/directory/"
|
7
|
+
#
|
8
|
+
# Excluding a file or directory (including sub-directories):
|
9
|
+
# archive.exclude "/path/to/an/excluded_file.rb"
|
10
|
+
# archive.exclude "/path/to/an/excluded_directory
|
11
|
+
#
|
12
|
+
# By default, relative paths will be relative to the directory
|
13
|
+
# where `backup perform` is executed, and they will be expanded
|
14
|
+
# to the root of the filesystem when added to the archive.
|
15
|
+
#
|
16
|
+
# If a `root` path is set, relative paths will be relative to the
|
17
|
+
# given `root` path and will not be expanded when added to the archive.
|
18
|
+
#
|
19
|
+
# archive.root '/path/to/archive/root'
|
20
|
+
#
|
21
|
+
archive :my_archive do |archive|
|
22
|
+
# Run the `tar` command using `sudo`
|
23
|
+
# archive.use_sudo
|
24
|
+
archive.add "/path/to/a/file.rb"
|
25
|
+
archive.add "/path/to/a/folder/"
|
26
|
+
archive.exclude "/path/to/a/excluded_file.rb"
|
27
|
+
archive.exclude "/path/to/a/excluded_folder"
|
28
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
##
|
4
|
+
# Backup v<%= Backup::VERSION.split('.').first %>.x Configuration
|
5
|
+
#
|
6
|
+
# Documentation: http://backup.github.io/backup
|
7
|
+
# Issue Tracker: https://github.com/backup/backup/issues
|
8
|
+
|
9
|
+
##
|
10
|
+
# Config Options
|
11
|
+
#
|
12
|
+
# The options here may be overridden on the command line, but the result
|
13
|
+
# will depend on the use of --root-path on the command line.
|
14
|
+
#
|
15
|
+
# If --root-path is used on the command line, then all paths set here
|
16
|
+
# will be overridden. If a path (like --tmp-path) is not given along with
|
17
|
+
# --root-path, that path will use it's default location _relative to --root-path_.
|
18
|
+
#
|
19
|
+
# If --root-path is not used on the command line, a path option (like --tmp-path)
|
20
|
+
# given on the command line will override the tmp_path set here, but all other
|
21
|
+
# paths set here will be used.
|
22
|
+
#
|
23
|
+
# Note that relative paths given on the command line without --root-path
|
24
|
+
# are relative to the current directory. The root_path set here only applies
|
25
|
+
# to relative paths set here.
|
26
|
+
#
|
27
|
+
# ---
|
28
|
+
#
|
29
|
+
# Sets the root path for all relative paths, including default paths.
|
30
|
+
# May be an absolute path, or relative to the current working directory.
|
31
|
+
#
|
32
|
+
# root_path 'my/root'
|
33
|
+
#
|
34
|
+
# Sets the path where backups are processed until they're stored.
|
35
|
+
# This must have enough free space to hold apx. 2 backups.
|
36
|
+
# May be an absolute path, or relative to the current directory or +root_path+.
|
37
|
+
#
|
38
|
+
# tmp_path 'my/tmp'
|
39
|
+
#
|
40
|
+
# Sets the path where backup stores persistent information.
|
41
|
+
# When Backup's Cycler is used, small YAML files are stored here.
|
42
|
+
# May be an absolute path, or relative to the current directory or +root_path+.
|
43
|
+
#
|
44
|
+
# data_path 'my/data'
|
45
|
+
|
46
|
+
##
|
47
|
+
# Utilities
|
48
|
+
#
|
49
|
+
# If you need to use a utility other than the one Backup detects,
|
50
|
+
# or a utility can not be found in your $PATH.
|
51
|
+
#
|
52
|
+
# Utilities.configure do
|
53
|
+
# tar '/usr/bin/gnutar'
|
54
|
+
# redis_cli '/opt/redis/redis-cli'
|
55
|
+
# end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Logging
|
59
|
+
#
|
60
|
+
# Logging options may be set on the command line, but certain settings
|
61
|
+
# may only be configured here.
|
62
|
+
#
|
63
|
+
# Logger.configure do
|
64
|
+
# console.quiet = true # Same as command line: --quiet
|
65
|
+
# logfile.max_bytes = 2_000_000 # Default: 500_000
|
66
|
+
# syslog.enabled = true # Same as command line: --syslog
|
67
|
+
# syslog.ident = 'my_app_backup' # Default: 'backup'
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# Command line options will override those set here.
|
71
|
+
# For example, the following would override the example settings above
|
72
|
+
# to disable syslog and enable console output.
|
73
|
+
# backup perform --trigger my_backup --no-syslog --no-quiet
|
74
|
+
|
75
|
+
##
|
76
|
+
# Component Defaults
|
77
|
+
#
|
78
|
+
# Set default options to be applied to components in all models.
|
79
|
+
# Options set within a model will override those set here.
|
80
|
+
#
|
81
|
+
# Storage::S3.defaults do |s3|
|
82
|
+
# s3.access_key_id = "my_access_key_id"
|
83
|
+
# s3.secret_access_key = "my_secret_access_key"
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# Notifier::Mail.defaults do |mail|
|
87
|
+
# mail.from = 'sender@email.com'
|
88
|
+
# mail.to = 'receiver@email.com'
|
89
|
+
# mail.address = 'smtp.gmail.com'
|
90
|
+
# mail.port = 587
|
91
|
+
# mail.domain = 'your.host.name'
|
92
|
+
# mail.user_name = 'sender@email.com'
|
93
|
+
# mail.password = 'my_password'
|
94
|
+
# mail.authentication = 'plain'
|
95
|
+
# mail.encryption = :starttls
|
96
|
+
# end
|
97
|
+
|
98
|
+
##
|
99
|
+
# Preconfigured Models
|
100
|
+
#
|
101
|
+
# Create custom models with preconfigured components.
|
102
|
+
# Components added within the model definition will
|
103
|
+
# +add to+ the preconfigured components.
|
104
|
+
#
|
105
|
+
# preconfigure 'MyModel' do
|
106
|
+
# archive :user_pictures do |archive|
|
107
|
+
# archive.add '~/pictures'
|
108
|
+
# end
|
109
|
+
#
|
110
|
+
# notify_by Mail do |mail|
|
111
|
+
# mail.to = 'admin@email.com'
|
112
|
+
# end
|
113
|
+
# end
|
114
|
+
#
|
115
|
+
# MyModel.new(:john_smith, 'John Smith Backup') do
|
116
|
+
# archive :user_music do |archive|
|
117
|
+
# archive.add '~/music'
|
118
|
+
# end
|
119
|
+
#
|
120
|
+
# notify_by Mail do |mail|
|
121
|
+
# mail.to = 'john.smith@email.com'
|
122
|
+
# end
|
123
|
+
# end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
##
|
2
|
+
# MongoDB [Database]
|
3
|
+
#
|
4
|
+
database MongoDB do |db|
|
5
|
+
db.name = "my_database_name"
|
6
|
+
db.username = "my_username"
|
7
|
+
db.password = "my_password"
|
8
|
+
db.host = "localhost"
|
9
|
+
db.port = 27017
|
10
|
+
db.ipv6 = false
|
11
|
+
db.only_collections = ["only", "these", "collections"]
|
12
|
+
db.additional_options = []
|
13
|
+
db.lock = false
|
14
|
+
db.oplog = false
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
##
|
2
|
+
# MySQL [Database]
|
3
|
+
#
|
4
|
+
database MySQL do |db|
|
5
|
+
# To dump all databases, set `db.name = :all` (or leave blank)
|
6
|
+
db.name = "my_database_name"
|
7
|
+
db.username = "my_username"
|
8
|
+
db.password = "my_password"
|
9
|
+
db.host = "localhost"
|
10
|
+
db.port = 3306
|
11
|
+
db.socket = "/tmp/mysql.sock"
|
12
|
+
# Note: when using `skip_tables` with the `db.name = :all` option,
|
13
|
+
# table names should be prefixed with a database name.
|
14
|
+
# e.g. ["db_name.table_to_skip", ...]
|
15
|
+
db.skip_tables = ["skip", "these", "tables"]
|
16
|
+
db.only_tables = ["only", "these", "tables"]
|
17
|
+
db.additional_options = ["--quick", "--single-transaction"]
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
##
|
2
|
+
# OpenLDAP [Database]
|
3
|
+
#
|
4
|
+
database OpenLDAP do |db|
|
5
|
+
# Name of the ldap backup
|
6
|
+
db.name = "my_database_name"
|
7
|
+
|
8
|
+
# Additional "slapcat" options
|
9
|
+
# defaults to an empty list of options
|
10
|
+
# db.slapcat_args = []
|
11
|
+
|
12
|
+
# run slapcat under sudo if needed
|
13
|
+
# defaults to "false"
|
14
|
+
# db.use_sudo = true
|
15
|
+
|
16
|
+
# Stores the location of the slapd.conf,
|
17
|
+
# defaults to "/etc/ldap/slapd.d" confdir
|
18
|
+
# you can use also conf file instead of directory
|
19
|
+
# db.slapcat_conf = /path/to/slapd.conf
|
20
|
+
|
21
|
+
# Optional: Use to set the location of slapcat utility
|
22
|
+
# if it cannot be found by name in your $PATH
|
23
|
+
# db.slapcat_utility = "/opt/local/bin/slapcat"
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
##
|
2
|
+
# PostgreSQL [Database]
|
3
|
+
#
|
4
|
+
database PostgreSQL do |db|
|
5
|
+
# To dump all databases, set `db.name = :all` (or leave blank)
|
6
|
+
db.name = "my_database_name"
|
7
|
+
db.username = "my_username"
|
8
|
+
db.password = "my_password"
|
9
|
+
db.host = "localhost"
|
10
|
+
db.port = 5432
|
11
|
+
db.socket = "/tmp/pg.sock"
|
12
|
+
# When dumping all databases, `skip_tables` and `only_tables` are ignored.
|
13
|
+
db.skip_tables = ["skip", "these", "tables"]
|
14
|
+
db.only_tables = ["only", "these", "tables"]
|
15
|
+
db.additional_options = ["-xc", "-E=utf8"]
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
##
|
2
|
+
# Redis [Database]
|
3
|
+
#
|
4
|
+
database Redis do |db|
|
5
|
+
db.mode = :copy # or :sync
|
6
|
+
# Full path to redis dump file for :copy mode.
|
7
|
+
db.rdb_path = '/var/lib/redis/dump.rdb'
|
8
|
+
# When :copy mode is used, perform a SAVE before
|
9
|
+
# copying the dump file specified by `rdb_path`.
|
10
|
+
db.invoke_save = false
|
11
|
+
db.host = 'localhost'
|
12
|
+
db.port = 6379
|
13
|
+
db.socket = '/tmp/redis.sock'
|
14
|
+
db.password = 'my_password'
|
15
|
+
db.additional_options = []
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
##
|
2
|
+
# Riak [Database]
|
3
|
+
#
|
4
|
+
database Riak do |db|
|
5
|
+
##
|
6
|
+
# The node from which to perform the backup.
|
7
|
+
# default: 'riak@127.0.0.1'
|
8
|
+
db.node = 'riak@hostname'
|
9
|
+
##
|
10
|
+
# The Erlang cookie/shared secret used to connect to the node.
|
11
|
+
# default: 'riak'
|
12
|
+
db.cookie = 'cookie'
|
13
|
+
##
|
14
|
+
# The user for the Riak instance.
|
15
|
+
# default: 'riak'
|
16
|
+
db.user = 'riak'
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
##
|
2
|
+
# SQLite [Database]
|
3
|
+
#
|
4
|
+
database SQLite do |db|
|
5
|
+
# Path to database file
|
6
|
+
db.path = "/path/to/my/sqlite/db.sqlite"
|
7
|
+
|
8
|
+
# Optional: Use to set the location of this utility
|
9
|
+
# if it cannot be found by name in your $PATH
|
10
|
+
db.sqlitedump_utility = "/opt/local/bin/sqlite3"
|
11
|
+
end
|