backup 3.0.19 → 3.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +9 -8
- data/Gemfile.lock +19 -1
- data/Guardfile +13 -9
- data/README.md +93 -31
- data/backup.gemspec +3 -3
- data/bin/backup +6 -283
- data/lib/backup.rb +101 -72
- data/lib/backup/archive.rb +21 -9
- data/lib/backup/binder.rb +22 -0
- data/lib/backup/cleaner.rb +36 -0
- data/lib/backup/cli/helpers.rb +103 -0
- data/lib/backup/cli/utility.rb +308 -0
- data/lib/backup/compressor/base.rb +2 -2
- data/lib/backup/compressor/pbzip2.rb +76 -0
- data/lib/backup/configuration/compressor/pbzip2.rb +28 -0
- data/lib/backup/configuration/database/riak.rb +25 -0
- data/lib/backup/configuration/encryptor/open_ssl.rb +6 -0
- data/lib/backup/configuration/helpers.rb +5 -18
- data/lib/backup/configuration/notifier/base.rb +13 -0
- data/lib/backup/configuration/notifier/hipchat.rb +41 -0
- data/lib/backup/configuration/notifier/mail.rb +38 -0
- data/lib/backup/configuration/notifier/prowl.rb +23 -0
- data/lib/backup/configuration/storage/cloudfiles.rb +4 -0
- data/lib/backup/configuration/storage/dropbox.rb +8 -4
- data/lib/backup/database/base.rb +10 -2
- data/lib/backup/database/mongodb.rb +16 -19
- data/lib/backup/database/mysql.rb +2 -2
- data/lib/backup/database/postgresql.rb +2 -2
- data/lib/backup/database/redis.rb +15 -7
- data/lib/backup/database/riak.rb +45 -0
- data/lib/backup/dependency.rb +21 -7
- data/lib/backup/encryptor/base.rb +1 -1
- data/lib/backup/encryptor/open_ssl.rb +20 -5
- data/lib/backup/errors.rb +124 -0
- data/lib/backup/finder.rb +11 -3
- data/lib/backup/logger.rb +121 -82
- data/lib/backup/model.rb +103 -44
- data/lib/backup/notifier/base.rb +50 -0
- data/lib/backup/notifier/campfire.rb +32 -52
- data/lib/backup/notifier/hipchat.rb +99 -0
- data/lib/backup/notifier/mail.rb +100 -61
- data/lib/backup/notifier/presently.rb +31 -40
- data/lib/backup/notifier/prowl.rb +73 -0
- data/lib/backup/notifier/twitter.rb +29 -39
- data/lib/backup/packager.rb +25 -0
- data/lib/backup/splitter.rb +62 -0
- data/lib/backup/storage/base.rb +178 -18
- data/lib/backup/storage/cloudfiles.rb +34 -28
- data/lib/backup/storage/dropbox.rb +64 -67
- data/lib/backup/storage/ftp.rb +48 -40
- data/lib/backup/storage/local.rb +33 -28
- data/lib/backup/storage/ninefold.rb +40 -26
- data/lib/backup/storage/object.rb +8 -6
- data/lib/backup/storage/rsync.rb +61 -51
- data/lib/backup/storage/s3.rb +29 -27
- data/lib/backup/storage/scp.rb +56 -36
- data/lib/backup/storage/sftp.rb +49 -33
- data/lib/backup/syncer/base.rb +1 -1
- data/lib/backup/syncer/rsync.rb +1 -1
- data/lib/backup/template.rb +46 -0
- data/lib/backup/version.rb +1 -1
- data/spec/archive_spec.rb +34 -9
- data/spec/backup_spec.rb +1 -1
- data/spec/cli/helpers_spec.rb +35 -0
- data/spec/cli/utility_spec.rb +38 -0
- data/spec/compressor/bzip2_spec.rb +1 -1
- data/spec/compressor/gzip_spec.rb +1 -1
- data/spec/compressor/lzma_spec.rb +1 -1
- data/spec/compressor/pbzip2_spec.rb +63 -0
- data/spec/configuration/base_spec.rb +1 -1
- data/spec/configuration/compressor/bzip2_spec.rb +1 -1
- data/spec/configuration/compressor/gzip_spec.rb +1 -1
- data/spec/configuration/compressor/lzma_spec.rb +1 -1
- data/spec/configuration/database/base_spec.rb +1 -1
- data/spec/configuration/database/mongodb_spec.rb +1 -1
- data/spec/configuration/database/mysql_spec.rb +1 -1
- data/spec/configuration/database/postgresql_spec.rb +1 -1
- data/spec/configuration/database/redis_spec.rb +1 -1
- data/spec/configuration/database/riak_spec.rb +31 -0
- data/spec/configuration/encryptor/gpg_spec.rb +1 -1
- data/spec/configuration/encryptor/open_ssl_spec.rb +4 -1
- data/spec/configuration/notifier/campfire_spec.rb +1 -1
- data/spec/configuration/notifier/hipchat_spec.rb +43 -0
- data/spec/configuration/notifier/mail_spec.rb +34 -22
- data/spec/configuration/notifier/presently_spec.rb +1 -1
- data/spec/configuration/notifier/prowl_spec.rb +28 -0
- data/spec/configuration/notifier/twitter_spec.rb +1 -1
- data/spec/configuration/storage/cloudfiles_spec.rb +19 -16
- data/spec/configuration/storage/dropbox_spec.rb +1 -1
- data/spec/configuration/storage/ftp_spec.rb +1 -1
- data/spec/configuration/storage/local_spec.rb +1 -1
- data/spec/configuration/storage/ninefold_spec.rb +1 -1
- data/spec/configuration/storage/rsync_spec.rb +1 -1
- data/spec/configuration/storage/s3_spec.rb +1 -1
- data/spec/configuration/storage/scp_spec.rb +1 -1
- data/spec/configuration/storage/sftp_spec.rb +1 -1
- data/spec/configuration/syncer/rsync_spec.rb +1 -1
- data/spec/configuration/syncer/s3_spec.rb +1 -1
- data/spec/database/base_spec.rb +10 -1
- data/spec/database/mongodb_spec.rb +34 -7
- data/spec/database/mysql_spec.rb +8 -7
- data/spec/database/postgresql_spec.rb +8 -7
- data/spec/database/redis_spec.rb +39 -9
- data/spec/database/riak_spec.rb +50 -0
- data/spec/encryptor/gpg_spec.rb +1 -1
- data/spec/encryptor/open_ssl_spec.rb +77 -20
- data/spec/errors_spec.rb +306 -0
- data/spec/finder_spec.rb +91 -0
- data/spec/logger_spec.rb +254 -33
- data/spec/model_spec.rb +120 -15
- data/spec/notifier/campfire_spec.rb +127 -52
- data/spec/notifier/hipchat_spec.rb +193 -0
- data/spec/notifier/mail_spec.rb +290 -74
- data/spec/notifier/presently_spec.rb +290 -73
- data/spec/notifier/prowl_spec.rb +149 -0
- data/spec/notifier/twitter_spec.rb +106 -41
- data/spec/spec_helper.rb +8 -2
- data/spec/splitter_spec.rb +71 -0
- data/spec/storage/base_spec.rb +280 -19
- data/spec/storage/cloudfiles_spec.rb +38 -22
- data/spec/storage/dropbox_spec.rb +17 -13
- data/spec/storage/ftp_spec.rb +145 -55
- data/spec/storage/local_spec.rb +6 -6
- data/spec/storage/ninefold_spec.rb +70 -29
- data/spec/storage/object_spec.rb +44 -44
- data/spec/storage/rsync_spec.rb +186 -63
- data/spec/storage/s3_spec.rb +23 -24
- data/spec/storage/scp_spec.rb +116 -41
- data/spec/storage/sftp_spec.rb +124 -46
- data/spec/syncer/rsync_spec.rb +3 -3
- data/spec/syncer/s3_spec.rb +1 -1
- data/spec/version_spec.rb +1 -1
- data/templates/cli/utility/archive +13 -0
- data/{lib/templates → templates/cli/utility}/compressor/bzip2 +1 -1
- data/{lib/templates → templates/cli/utility}/compressor/gzip +1 -1
- data/{lib/templates → templates/cli/utility}/compressor/lzma +0 -0
- data/templates/cli/utility/compressor/pbzip2 +7 -0
- data/templates/cli/utility/config +31 -0
- data/{lib/templates → templates/cli/utility}/database/mongodb +1 -1
- data/{lib/templates → templates/cli/utility}/database/mysql +1 -1
- data/{lib/templates → templates/cli/utility}/database/postgresql +1 -1
- data/{lib/templates → templates/cli/utility}/database/redis +1 -1
- data/templates/cli/utility/database/riak +8 -0
- data/{lib/templates → templates/cli/utility}/encryptor/gpg +1 -1
- data/templates/cli/utility/encryptor/openssl +9 -0
- data/templates/cli/utility/model.erb +23 -0
- data/{lib/templates → templates/cli/utility}/notifier/campfire +2 -1
- data/templates/cli/utility/notifier/hipchat +15 -0
- data/{lib/templates → templates/cli/utility}/notifier/mail +6 -1
- data/{lib/templates → templates/cli/utility}/notifier/presently +1 -0
- data/templates/cli/utility/notifier/prowl +11 -0
- data/{lib/templates → templates/cli/utility}/notifier/twitter +2 -1
- data/templates/cli/utility/splitter +7 -0
- data/templates/cli/utility/storage/cloudfiles +12 -0
- data/{lib/templates → templates/cli/utility}/storage/dropbox +1 -1
- data/{lib/templates → templates/cli/utility}/storage/ftp +0 -0
- data/templates/cli/utility/storage/local +7 -0
- data/{lib/templates → templates/cli/utility}/storage/ninefold +1 -1
- data/templates/cli/utility/storage/rsync +11 -0
- data/{lib/templates → templates/cli/utility}/storage/s3 +0 -2
- data/templates/cli/utility/storage/scp +11 -0
- data/templates/cli/utility/storage/sftp +11 -0
- data/{lib/templates → templates/cli/utility}/syncer/rsync +1 -1
- data/{lib/templates → templates/cli/utility}/syncer/s3 +1 -1
- data/templates/general/links +11 -0
- data/templates/general/version.erb +2 -0
- data/templates/notifier/mail/failure.erb +9 -0
- data/templates/notifier/mail/success.erb +7 -0
- data/templates/notifier/mail/warning.erb +9 -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 +81 -45
- data/lib/backup/cli.rb +0 -110
- data/lib/backup/exception/command_failed.rb +0 -8
- data/lib/backup/exception/command_not_found.rb +0 -8
- data/lib/backup/notifier/binder.rb +0 -32
- data/lib/backup/notifier/templates/notify_failure.erb +0 -33
- data/lib/backup/notifier/templates/notify_success.erb +0 -16
- data/lib/templates/archive +0 -7
- data/lib/templates/encryptor/openssl +0 -8
- data/lib/templates/readme +0 -15
- data/lib/templates/storage/cloudfiles +0 -11
- data/lib/templates/storage/local +0 -7
- data/lib/templates/storage/rsync +0 -11
- data/lib/templates/storage/scp +0 -11
- data/lib/templates/storage/sftp +0 -11
@@ -3,14 +3,14 @@
|
|
3
3
|
module Backup
|
4
4
|
module Compressor
|
5
5
|
class Base
|
6
|
-
include Backup::CLI
|
6
|
+
include Backup::CLI::Helpers
|
7
7
|
include Backup::Configuration::Helpers
|
8
8
|
|
9
9
|
##
|
10
10
|
# Logs a message to the console and log file to inform
|
11
11
|
# the client that Backup is compressing the archive
|
12
12
|
def log!
|
13
|
-
|
13
|
+
Logger.message "#{ self.class } started compressing the archive."
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
module Compressor
|
5
|
+
class Pbzip2 < Base
|
6
|
+
|
7
|
+
##
|
8
|
+
# Tells Backup::Compressor::Pbzip2 to compress
|
9
|
+
# better (-9) rather than faster when set to true
|
10
|
+
attr_writer :best
|
11
|
+
|
12
|
+
##
|
13
|
+
# Tells Backup::Compressor::Pbzip2 to compress
|
14
|
+
# faster (-1) rather than better when set to true
|
15
|
+
attr_writer :fast
|
16
|
+
|
17
|
+
##
|
18
|
+
# Tells Backup::Compressor::Pbzip2 how many processors
|
19
|
+
# use, by default autodetect is used
|
20
|
+
attr_writer :processors
|
21
|
+
|
22
|
+
##
|
23
|
+
# Creates a new instance of Backup::Compressor::Pbzip2 and
|
24
|
+
# configures it to either compress faster or better
|
25
|
+
# bzip2 compresses by default with -9 (best compression)
|
26
|
+
# and lower block sizes don't make things significantly faster
|
27
|
+
# (according to official bzip2 docs)
|
28
|
+
def initialize(&block)
|
29
|
+
load_defaults!
|
30
|
+
|
31
|
+
@best ||= false
|
32
|
+
@fast ||= false
|
33
|
+
@processors ||= nil
|
34
|
+
|
35
|
+
instance_eval(&block) if block_given?
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Performs the compression of the packages backup file
|
40
|
+
def perform!
|
41
|
+
log!
|
42
|
+
run("#{ utility(:pbzip2) } #{ options } '#{ Backup::Model.file }'")
|
43
|
+
Backup::Model.extension += '.bz2'
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
##
|
49
|
+
# Combines the provided options and returns a pbzip2 options string
|
50
|
+
def options
|
51
|
+
(best + fast + processors).join("\s")
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Returns the pbzip2 option syntax for compressing
|
56
|
+
# setting @best to true is redundant, as pbzip2 compresses best by default
|
57
|
+
def best
|
58
|
+
return ['--best'] if @best; []
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# Returns the pbzip2 option syntax for compressing
|
63
|
+
# (not significantly) faster when @fast is set to true
|
64
|
+
def fast
|
65
|
+
return ['--fast'] if @fast; []
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# Returns the pbzip2 option syntax for compressing
|
70
|
+
# using given count of cpus
|
71
|
+
def processors
|
72
|
+
return ['-p' + @processors.to_s] if @processors; []
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
module Configuration
|
5
|
+
module Compressor
|
6
|
+
class Pbzip2 < Base
|
7
|
+
class << self
|
8
|
+
|
9
|
+
##
|
10
|
+
# Tells Backup::Compressor::Pbzip2 to compress
|
11
|
+
# better (-9) which is bzip2 default anyway
|
12
|
+
attr_accessor :best
|
13
|
+
|
14
|
+
##
|
15
|
+
# Tells Backup::Compressor::Pbzip2 to compress
|
16
|
+
# faster (-1) (but not significantly faster)
|
17
|
+
attr_accessor :fast
|
18
|
+
|
19
|
+
##
|
20
|
+
# Tells Backup::Compressor::Pbzip2 how many processors
|
21
|
+
# use, by default autodetect is used
|
22
|
+
attr_writer :processors
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
module Configuration
|
5
|
+
module Database
|
6
|
+
class Riak < Base
|
7
|
+
class << self
|
8
|
+
|
9
|
+
##
|
10
|
+
# Name is the name of the backup
|
11
|
+
attr_accessor :name
|
12
|
+
|
13
|
+
##
|
14
|
+
# Node is the node from which to perform the backup.
|
15
|
+
attr_accessor :node
|
16
|
+
|
17
|
+
##
|
18
|
+
# Cookie is the Erlang cookie/shared secret used to connect to the node.
|
19
|
+
attr_accessor :cookie
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -10,6 +10,12 @@ module Backup
|
|
10
10
|
# The password that'll be used to encrypt the backup. This
|
11
11
|
# password will be required to decrypt the backup later on.
|
12
12
|
attr_accessor :password
|
13
|
+
|
14
|
+
##
|
15
|
+
# The password file used for encrypting the backup. This
|
16
|
+
# password file will be required to decrypt the backup later
|
17
|
+
# on.
|
18
|
+
attr_accessor :password_file
|
13
19
|
|
14
20
|
##
|
15
21
|
# Determines whether the 'base64' should be used or not
|
@@ -8,21 +8,13 @@ module Backup
|
|
8
8
|
# Finds all the object's getter methods and checks the global
|
9
9
|
# configuration for these methods, if they respond then they will
|
10
10
|
# assign the object's attribute(s) to that particular global configuration's attribute
|
11
|
-
def load_defaults!
|
11
|
+
def load_defaults!
|
12
12
|
c = self.class.name.split('::')
|
13
13
|
configuration = Backup::Configuration.const_get(c[1]).const_get(c[2])
|
14
|
-
options[:except] ||= []
|
15
|
-
options[:only] ||= []
|
16
14
|
|
17
15
|
getter_methods.each do |attribute|
|
18
16
|
if configuration.respond_to?(attribute)
|
19
|
-
|
20
|
-
self.send("#{attribute}=", configuration.send(attribute))
|
21
|
-
elsif options[:except].any? and !options[:except].include?(attribute)
|
22
|
-
self.send("#{attribute}=", configuration.send(attribute))
|
23
|
-
elsif options[:only].empty? and options[:except].empty?
|
24
|
-
self.send("#{attribute}=", configuration.send(attribute))
|
25
|
-
end
|
17
|
+
self.send("#{attribute}=", configuration.send(attribute))
|
26
18
|
end
|
27
19
|
end
|
28
20
|
end
|
@@ -36,7 +28,7 @@ module Backup
|
|
36
28
|
end
|
37
29
|
|
38
30
|
##
|
39
|
-
# Returns an
|
31
|
+
# Returns an Array of the setter methods (as String)
|
40
32
|
def setter_methods
|
41
33
|
methods.map do |method|
|
42
34
|
method = method.to_s
|
@@ -45,14 +37,9 @@ module Backup
|
|
45
37
|
end
|
46
38
|
|
47
39
|
##
|
48
|
-
# Returns an
|
40
|
+
# Returns an Array of getter methods (as String)
|
49
41
|
def getter_methods
|
50
|
-
|
51
|
-
method = method.to_s
|
52
|
-
if method =~ /^\w(\w|\d|\_)+\=$/ and method != 'taguri='
|
53
|
-
method.sub('=','')
|
54
|
-
end
|
55
|
-
end.compact
|
42
|
+
setter_methods.map {|method| method.sub('=','') }
|
56
43
|
end
|
57
44
|
|
58
45
|
end
|
@@ -11,6 +11,11 @@ module Backup
|
|
11
11
|
# when a backup process ends without raising any exceptions
|
12
12
|
attr_writer :on_success
|
13
13
|
|
14
|
+
##
|
15
|
+
# When set to true, the user will be notified by email
|
16
|
+
# when a backup process ends successfully, but logged warnings
|
17
|
+
attr_writer :on_warning
|
18
|
+
|
14
19
|
##
|
15
20
|
# When set to true, the user will be notified by email
|
16
21
|
# when a backup process raises an exception before finishing
|
@@ -26,6 +31,14 @@ module Backup
|
|
26
31
|
@on_success
|
27
32
|
end
|
28
33
|
|
34
|
+
##
|
35
|
+
# When @on_success is nil it means it hasn't been defined
|
36
|
+
# and will then default to true
|
37
|
+
def self.on_warning
|
38
|
+
return true if @on_warning.nil?
|
39
|
+
@on_warning
|
40
|
+
end
|
41
|
+
|
29
42
|
##
|
30
43
|
# When @on_failure is nil it means it hasn't been defined
|
31
44
|
# and will then default to true
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
module Configuration
|
5
|
+
module Notifier
|
6
|
+
class Hipchat < Base
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# From
|
10
|
+
# Name that appears in Hipchat
|
11
|
+
attr_accessor :from
|
12
|
+
|
13
|
+
# Hipchat API Token
|
14
|
+
# The token to interact with Hipchat
|
15
|
+
attr_accessor :token
|
16
|
+
|
17
|
+
# Rooms
|
18
|
+
# Rooms that you want to post notifications to
|
19
|
+
attr_accessor :rooms_notified
|
20
|
+
|
21
|
+
# Success Color
|
22
|
+
# The background color of a success message. One of :yellow, :red, :green, :purple, or :random. (default: yellow)
|
23
|
+
attr_accessor :success_color
|
24
|
+
|
25
|
+
# Warning Color
|
26
|
+
# The background color of a success message. One of :yellow, :red, :green, :purple, or :random. (default: yellow)
|
27
|
+
attr_accessor :warning_color
|
28
|
+
|
29
|
+
# Failure Color
|
30
|
+
# The background color of an error message. One of :yellow, :red, :green, :purple, or :random. (default: yellow)
|
31
|
+
attr_accessor :failure_color
|
32
|
+
|
33
|
+
# Notify Users
|
34
|
+
# (bool) Notify users in the room
|
35
|
+
attr_accessor :notify_users
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -6,6 +6,25 @@ module Backup
|
|
6
6
|
class Mail < Base
|
7
7
|
class << self
|
8
8
|
|
9
|
+
##
|
10
|
+
# Mail delivery method to be used by the Mail gem.
|
11
|
+
# Supported methods:
|
12
|
+
#
|
13
|
+
# `:smtp` [::Mail::SMTP] (default)
|
14
|
+
# : Settings used only by this method:
|
15
|
+
# : `address`, `port`, `domain`, `user_name`, `password`
|
16
|
+
# : `authentication`, `enable_starttls_auto`, `openssl_verify_mode`
|
17
|
+
#
|
18
|
+
# `:sendmail` [::Mail::Sendmail]
|
19
|
+
# : Settings used only by this method:
|
20
|
+
# : `sendmail`, `sendmail_args`
|
21
|
+
#
|
22
|
+
# `:file` [::Mail::FileDelivery]
|
23
|
+
# : Settings used only by this method:
|
24
|
+
# : `mail_folder`
|
25
|
+
#
|
26
|
+
attr_accessor :delivery_method
|
27
|
+
|
9
28
|
##
|
10
29
|
# Sender and Receiver email addresses
|
11
30
|
# Examples:
|
@@ -50,6 +69,25 @@ module Backup
|
|
50
69
|
# Example: none - Only use this option for a self-signed and/or wildcard certificate
|
51
70
|
attr_accessor :openssl_verify_mode
|
52
71
|
|
72
|
+
##
|
73
|
+
# When using the `:sendmail` `delivery_method` option,
|
74
|
+
# this may be used to specify the absolute path to `sendmail` (if needed)
|
75
|
+
# Example: '/usr/sbin/sendmail'
|
76
|
+
attr_accessor :sendmail
|
77
|
+
|
78
|
+
##
|
79
|
+
# Optional arguments to pass to `sendmail`
|
80
|
+
# Note that this will override the defaults set by the Mail gem (currently: '-i -t')
|
81
|
+
# So, if set here, be sure to set all the arguments you require.
|
82
|
+
# Example: '-i -t -X/tmp/traffic.log'
|
83
|
+
attr_accessor :sendmail_args
|
84
|
+
|
85
|
+
##
|
86
|
+
# Folder where mail will be kept when using the `:file` `delivery_method` option.
|
87
|
+
# Default location is '$HOME/backup-mails'
|
88
|
+
# Example: '/tmp/test-mails'
|
89
|
+
attr_accessor :mail_folder
|
90
|
+
|
53
91
|
end
|
54
92
|
end
|
55
93
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
module Configuration
|
5
|
+
module Notifier
|
6
|
+
class Prowl < Base
|
7
|
+
class << self
|
8
|
+
|
9
|
+
##
|
10
|
+
# Application name
|
11
|
+
# Tell something like your server name. Example: "Server1 Backup"
|
12
|
+
attr_accessor :application
|
13
|
+
|
14
|
+
##
|
15
|
+
# API-Key
|
16
|
+
# Create a Prowl account and request an API key on prowlapp.com.
|
17
|
+
attr_accessor :api_key
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -10,6 +10,10 @@ module Backup
|
|
10
10
|
# Rackspace Cloud Files Credentials
|
11
11
|
attr_accessor :api_key, :username, :auth_url
|
12
12
|
|
13
|
+
##
|
14
|
+
# Rackspace Service Net (Allows for LAN-based transfers to avoid charges and improve performance)
|
15
|
+
attr_accessor :servicenet
|
16
|
+
|
13
17
|
##
|
14
18
|
# Rackspace Cloud Files container name and path
|
15
19
|
attr_accessor :container, :path
|
@@ -22,19 +22,23 @@ module Backup
|
|
22
22
|
# DEPRECATED METHODS #############################################
|
23
23
|
|
24
24
|
def email
|
25
|
-
Logger.warn "[DEPRECATED] Backup::Configuration::Storage::Dropbox.email
|
25
|
+
Logger.warn "[DEPRECATED] Backup::Configuration::Storage::Dropbox.email\n" +
|
26
|
+
" is deprecated and will be removed at some point."
|
26
27
|
end
|
27
28
|
|
28
29
|
def email=(value)
|
29
|
-
Logger.warn "[DEPRECATED] Backup::Configuration::Storage::Dropbox.email
|
30
|
+
Logger.warn "[DEPRECATED] Backup::Configuration::Storage::Dropbox.email=\n" +
|
31
|
+
" is deprecated and will be removed at some point."
|
30
32
|
end
|
31
33
|
|
32
34
|
def password
|
33
|
-
Logger.warn "[DEPRECATED] Backup::Configuration::Storage::Dropbox.password
|
35
|
+
Logger.warn "[DEPRECATED] Backup::Configuration::Storage::Dropbox.password\n" +
|
36
|
+
" is deprecated and will be removed at some point."
|
34
37
|
end
|
35
38
|
|
36
39
|
def password=(value)
|
37
|
-
Logger.warn "[DEPRECATED] Backup::Configuration::Storage::Dropbox.password
|
40
|
+
Logger.warn "[DEPRECATED] Backup::Configuration::Storage::Dropbox.password=\n" +
|
41
|
+
" is deprecated and will be removed at some point."
|
38
42
|
end
|
39
43
|
|
40
44
|
end
|
data/lib/backup/database/base.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Backup
|
4
4
|
module Database
|
5
5
|
class Base
|
6
|
-
include Backup::CLI
|
6
|
+
include Backup::CLI::Helpers
|
7
7
|
include Backup::Configuration::Helpers
|
8
8
|
|
9
9
|
##
|
@@ -15,6 +15,14 @@ module Backup
|
|
15
15
|
# in case it cannot be auto-detected by Backup
|
16
16
|
attr_accessor :utility_path
|
17
17
|
|
18
|
+
##
|
19
|
+
# Super method for all child (database) objects. Every database object's #perform!
|
20
|
+
# method should call #super before anything else to prepare
|
21
|
+
def perform!
|
22
|
+
prepare!
|
23
|
+
log!
|
24
|
+
end
|
25
|
+
|
18
26
|
##
|
19
27
|
# Defines the @dump_path and ensures it exists by creating it
|
20
28
|
def prepare!
|
@@ -26,7 +34,7 @@ module Backup
|
|
26
34
|
# Logs a message to the console and log file to inform
|
27
35
|
# the client that Backup is dumping the database
|
28
36
|
def log!
|
29
|
-
Logger.message
|
37
|
+
Logger.message "#{self.class} started dumping and archiving '#{ name }'."
|
30
38
|
end
|
31
39
|
end
|
32
40
|
end
|
@@ -43,7 +43,6 @@ module Backup
|
|
43
43
|
@lock ||= false
|
44
44
|
|
45
45
|
instance_eval(&block)
|
46
|
-
prepare!
|
47
46
|
end
|
48
47
|
|
49
48
|
##
|
@@ -112,20 +111,18 @@ module Backup
|
|
112
111
|
# collections to dump, it'll loop through the array of collections and invoke the
|
113
112
|
# 'mongodump' command once per collection
|
114
113
|
def perform!
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
dump!
|
123
|
-
end
|
124
|
-
unlock_database if @lock.eql?(true)
|
125
|
-
rescue => exception
|
126
|
-
unlock_database if @lock.eql?(true)
|
127
|
-
raise exception
|
114
|
+
super
|
115
|
+
|
116
|
+
lock_database if @lock.eql?(true)
|
117
|
+
if collections_to_dump.is_a?(Array) and not collections_to_dump.empty?
|
118
|
+
specific_collection_dump!
|
119
|
+
else
|
120
|
+
dump!
|
128
121
|
end
|
122
|
+
unlock_database if @lock.eql?(true)
|
123
|
+
rescue => exception
|
124
|
+
unlock_database if @lock.eql?(true)
|
125
|
+
raise exception
|
129
126
|
end
|
130
127
|
|
131
128
|
##
|
@@ -145,9 +142,9 @@ module Backup
|
|
145
142
|
end
|
146
143
|
|
147
144
|
##
|
148
|
-
# Builds
|
149
|
-
def
|
150
|
-
[
|
145
|
+
# Builds a Mongo URI based on the provided attributes
|
146
|
+
def mongo_uri
|
147
|
+
["#{ host }:#{ port }#{ name.is_a?(String) && !name.empty? ? "/#{ name }" : "" }", credential_options, ipv6].join(' ').strip
|
151
148
|
end
|
152
149
|
|
153
150
|
##
|
@@ -157,7 +154,7 @@ module Backup
|
|
157
154
|
def lock_database
|
158
155
|
lock_command = <<-EOS
|
159
156
|
echo 'use admin
|
160
|
-
db.runCommand({"fsync" : 1, "lock" : 1})' | #{
|
157
|
+
db.runCommand({"fsync" : 1, "lock" : 1})' | #{ "#{ utility(:mongo) } #{ mongo_uri }" }
|
161
158
|
EOS
|
162
159
|
|
163
160
|
run(lock_command)
|
@@ -168,7 +165,7 @@ module Backup
|
|
168
165
|
def unlock_database
|
169
166
|
unlock_command = <<-EOS
|
170
167
|
echo 'use admin
|
171
|
-
db.$cmd.sys.unlock.findOne()' | #{
|
168
|
+
db.$cmd.sys.unlock.findOne()' | #{ "#{ utility(:mongo) } #{ mongo_uri }" }
|
172
169
|
EOS
|
173
170
|
|
174
171
|
run(unlock_command)
|