backup 3.0.23 → 3.0.24
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +42 -45
- data/Guardfile +7 -4
- data/README.md +10 -7
- data/backup.gemspec +2 -2
- data/lib/backup.rb +27 -97
- data/lib/backup/archive.rb +14 -6
- data/lib/backup/cli/helpers.rb +52 -49
- data/lib/backup/cli/utility.rb +9 -1
- data/lib/backup/compressor/base.rb +10 -4
- data/lib/backup/compressor/bzip2.rb +22 -26
- data/lib/backup/compressor/custom.rb +53 -0
- data/lib/backup/compressor/gzip.rb +22 -23
- data/lib/backup/compressor/lzma.rb +15 -13
- data/lib/backup/compressor/pbzip2.rb +20 -17
- data/lib/backup/config.rb +6 -3
- data/lib/backup/configuration.rb +33 -0
- data/lib/backup/configuration/helpers.rb +114 -28
- data/lib/backup/configuration/store.rb +24 -0
- data/lib/backup/database/base.rb +0 -6
- data/lib/backup/database/mongodb.rb +27 -11
- data/lib/backup/database/mysql.rb +19 -14
- data/lib/backup/database/postgresql.rb +16 -11
- data/lib/backup/database/redis.rb +7 -11
- data/lib/backup/database/riak.rb +3 -6
- data/lib/backup/dependency.rb +5 -11
- data/lib/backup/model.rb +14 -5
- data/lib/backup/notifier/campfire.rb +3 -16
- data/lib/backup/notifier/hipchat.rb +1 -7
- data/lib/backup/notifier/mail.rb +1 -1
- data/lib/backup/packager.rb +29 -19
- data/lib/backup/pipeline.rb +110 -0
- data/lib/backup/storage/dropbox.rb +4 -7
- data/lib/backup/syncer/base.rb +8 -4
- data/lib/backup/syncer/cloud/base.rb +247 -0
- data/lib/backup/syncer/cloud/cloud_files.rb +78 -0
- data/lib/backup/syncer/cloud/s3.rb +68 -0
- data/lib/backup/syncer/rsync/base.rb +1 -4
- data/lib/backup/syncer/rsync/local.rb +9 -5
- data/lib/backup/syncer/rsync/pull.rb +1 -1
- data/lib/backup/syncer/rsync/push.rb +10 -5
- data/lib/backup/version.rb +1 -1
- data/spec-live/.gitignore +6 -0
- data/spec-live/README +7 -0
- data/spec-live/backups/config.rb +153 -0
- data/spec-live/backups/config.yml.template +43 -0
- data/spec-live/compressor/custom_spec.rb +30 -0
- data/spec-live/compressor/gzip_spec.rb +30 -0
- data/spec-live/notifier/mail_spec.rb +85 -0
- data/spec-live/spec_helper.rb +85 -0
- data/spec-live/storage/dropbox_spec.rb +151 -0
- data/spec-live/storage/local_spec.rb +83 -0
- data/spec-live/storage/scp_spec.rb +193 -0
- data/spec-live/syncer/cloud/s3_spec.rb +124 -0
- data/spec/archive_spec.rb +86 -31
- data/spec/cleaner_spec.rb +8 -0
- data/spec/cli/helpers_spec.rb +200 -75
- data/spec/cli/utility_spec.rb +11 -3
- data/spec/compressor/base_spec.rb +31 -10
- data/spec/compressor/bzip2_spec.rb +212 -57
- data/spec/compressor/custom_spec.rb +106 -0
- data/spec/compressor/gzip_spec.rb +212 -57
- data/spec/compressor/lzma_spec.rb +75 -35
- data/spec/compressor/pbzip2_spec.rb +93 -52
- data/spec/configuration/helpers_spec.rb +406 -0
- data/spec/configuration/store_spec.rb +39 -0
- data/spec/configuration_spec.rb +62 -0
- data/spec/database/base_spec.rb +19 -10
- data/spec/database/mongodb_spec.rb +195 -70
- data/spec/database/mysql_spec.rb +183 -64
- data/spec/database/postgresql_spec.rb +167 -53
- data/spec/database/redis_spec.rb +121 -46
- data/spec/database/riak_spec.rb +96 -27
- data/spec/dependency_spec.rb +2 -0
- data/spec/encryptor/base_spec.rb +10 -0
- data/spec/encryptor/gpg_spec.rb +29 -13
- data/spec/encryptor/open_ssl_spec.rb +40 -21
- data/spec/logger_spec.rb +4 -0
- data/spec/model_spec.rb +19 -2
- data/spec/notifier/base_spec.rb +32 -17
- data/spec/notifier/campfire_spec.rb +63 -45
- data/spec/notifier/hipchat_spec.rb +79 -56
- data/spec/notifier/mail_spec.rb +82 -46
- data/spec/notifier/prowl_spec.rb +53 -32
- data/spec/notifier/twitter_spec.rb +62 -41
- data/spec/packager_spec.rb +95 -36
- data/spec/pipeline_spec.rb +259 -0
- data/spec/spec_helper.rb +6 -5
- data/spec/storage/base_spec.rb +61 -41
- data/spec/storage/cloudfiles_spec.rb +69 -45
- data/spec/storage/dropbox_spec.rb +158 -36
- data/spec/storage/ftp_spec.rb +69 -45
- data/spec/storage/local_spec.rb +47 -23
- data/spec/storage/ninefold_spec.rb +55 -31
- data/spec/storage/rsync_spec.rb +67 -50
- data/spec/storage/s3_spec.rb +65 -41
- data/spec/storage/scp_spec.rb +65 -41
- data/spec/storage/sftp_spec.rb +65 -41
- data/spec/syncer/base_spec.rb +91 -4
- data/spec/syncer/cloud/base_spec.rb +511 -0
- data/spec/syncer/cloud/cloud_files_spec.rb +181 -0
- data/spec/syncer/cloud/s3_spec.rb +174 -0
- data/spec/syncer/rsync/base_spec.rb +46 -66
- data/spec/syncer/rsync/local_spec.rb +55 -26
- data/spec/syncer/rsync/pull_spec.rb +15 -4
- data/spec/syncer/rsync/push_spec.rb +59 -52
- data/templates/cli/utility/compressor/bzip2 +1 -4
- data/templates/cli/utility/compressor/custom +11 -0
- data/templates/cli/utility/compressor/gzip +1 -4
- data/templates/cli/utility/compressor/lzma +3 -0
- data/templates/cli/utility/compressor/pbzip2 +3 -0
- data/templates/cli/utility/database/mysql +4 -1
- data/templates/cli/utility/syncer/cloud_files +17 -19
- data/templates/cli/utility/syncer/s3 +18 -20
- metadata +38 -92
- data/lib/backup/configuration/base.rb +0 -15
- data/lib/backup/configuration/compressor/base.rb +0 -9
- data/lib/backup/configuration/compressor/bzip2.rb +0 -23
- data/lib/backup/configuration/compressor/gzip.rb +0 -23
- data/lib/backup/configuration/compressor/lzma.rb +0 -23
- data/lib/backup/configuration/compressor/pbzip2.rb +0 -28
- data/lib/backup/configuration/database/base.rb +0 -19
- data/lib/backup/configuration/database/mongodb.rb +0 -49
- data/lib/backup/configuration/database/mysql.rb +0 -42
- data/lib/backup/configuration/database/postgresql.rb +0 -41
- data/lib/backup/configuration/database/redis.rb +0 -39
- data/lib/backup/configuration/database/riak.rb +0 -29
- data/lib/backup/configuration/encryptor/base.rb +0 -9
- data/lib/backup/configuration/encryptor/gpg.rb +0 -17
- data/lib/backup/configuration/encryptor/open_ssl.rb +0 -32
- data/lib/backup/configuration/notifier/base.rb +0 -28
- data/lib/backup/configuration/notifier/campfire.rb +0 -25
- data/lib/backup/configuration/notifier/hipchat.rb +0 -41
- data/lib/backup/configuration/notifier/mail.rb +0 -112
- data/lib/backup/configuration/notifier/presently.rb +0 -25
- data/lib/backup/configuration/notifier/prowl.rb +0 -23
- data/lib/backup/configuration/notifier/twitter.rb +0 -21
- data/lib/backup/configuration/storage/base.rb +0 -18
- data/lib/backup/configuration/storage/cloudfiles.rb +0 -25
- data/lib/backup/configuration/storage/dropbox.rb +0 -58
- data/lib/backup/configuration/storage/ftp.rb +0 -29
- data/lib/backup/configuration/storage/local.rb +0 -17
- data/lib/backup/configuration/storage/ninefold.rb +0 -20
- data/lib/backup/configuration/storage/rsync.rb +0 -29
- data/lib/backup/configuration/storage/s3.rb +0 -25
- data/lib/backup/configuration/storage/scp.rb +0 -25
- data/lib/backup/configuration/storage/sftp.rb +0 -25
- data/lib/backup/configuration/syncer/base.rb +0 -10
- data/lib/backup/configuration/syncer/cloud.rb +0 -23
- data/lib/backup/configuration/syncer/cloud_files.rb +0 -30
- data/lib/backup/configuration/syncer/rsync/base.rb +0 -28
- data/lib/backup/configuration/syncer/rsync/local.rb +0 -11
- data/lib/backup/configuration/syncer/rsync/pull.rb +0 -11
- data/lib/backup/configuration/syncer/rsync/push.rb +0 -31
- data/lib/backup/configuration/syncer/s3.rb +0 -23
- data/lib/backup/notifier/presently.rb +0 -88
- data/lib/backup/syncer/cloud.rb +0 -187
- data/lib/backup/syncer/cloud_files.rb +0 -56
- data/lib/backup/syncer/s3.rb +0 -47
- data/spec/configuration/base_spec.rb +0 -35
- data/spec/configuration/compressor/bzip2_spec.rb +0 -29
- data/spec/configuration/compressor/gzip_spec.rb +0 -29
- data/spec/configuration/compressor/lzma_spec.rb +0 -29
- data/spec/configuration/compressor/pbzip2_spec.rb +0 -32
- data/spec/configuration/database/base_spec.rb +0 -17
- data/spec/configuration/database/mongodb_spec.rb +0 -56
- data/spec/configuration/database/mysql_spec.rb +0 -53
- data/spec/configuration/database/postgresql_spec.rb +0 -53
- data/spec/configuration/database/redis_spec.rb +0 -50
- data/spec/configuration/database/riak_spec.rb +0 -35
- data/spec/configuration/encryptor/gpg_spec.rb +0 -26
- data/spec/configuration/encryptor/open_ssl_spec.rb +0 -35
- data/spec/configuration/notifier/base_spec.rb +0 -32
- data/spec/configuration/notifier/campfire_spec.rb +0 -32
- data/spec/configuration/notifier/hipchat_spec.rb +0 -44
- data/spec/configuration/notifier/mail_spec.rb +0 -71
- data/spec/configuration/notifier/presently_spec.rb +0 -35
- data/spec/configuration/notifier/prowl_spec.rb +0 -29
- data/spec/configuration/notifier/twitter_spec.rb +0 -35
- data/spec/configuration/storage/cloudfiles_spec.rb +0 -41
- data/spec/configuration/storage/dropbox_spec.rb +0 -38
- data/spec/configuration/storage/ftp_spec.rb +0 -44
- data/spec/configuration/storage/local_spec.rb +0 -29
- data/spec/configuration/storage/ninefold_spec.rb +0 -32
- data/spec/configuration/storage/rsync_spec.rb +0 -41
- data/spec/configuration/storage/s3_spec.rb +0 -38
- data/spec/configuration/storage/scp_spec.rb +0 -41
- data/spec/configuration/storage/sftp_spec.rb +0 -41
- data/spec/configuration/syncer/cloud_files_spec.rb +0 -44
- data/spec/configuration/syncer/rsync/base_spec.rb +0 -33
- data/spec/configuration/syncer/rsync/local_spec.rb +0 -10
- data/spec/configuration/syncer/rsync/pull_spec.rb +0 -10
- data/spec/configuration/syncer/rsync/push_spec.rb +0 -43
- data/spec/configuration/syncer/s3_spec.rb +0 -38
- data/spec/notifier/presently_spec.rb +0 -181
- data/spec/syncer/cloud_files_spec.rb +0 -192
- data/spec/syncer/s3_spec.rb +0 -192
- data/templates/cli/utility/notifier/presently +0 -13
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module Backup
|
6
|
+
module Configuration
|
7
|
+
class Store < OpenStruct
|
8
|
+
|
9
|
+
##
|
10
|
+
# Returns an Array of all attribute method names
|
11
|
+
# that default values were set for.
|
12
|
+
def _attributes
|
13
|
+
@table.keys
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# Used only within the specs
|
18
|
+
def reset!
|
19
|
+
@table.clear
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/backup/database/base.rb
CHANGED
@@ -6,12 +6,6 @@ module Backup
|
|
6
6
|
include Backup::CLI::Helpers
|
7
7
|
include Backup::Configuration::Helpers
|
8
8
|
|
9
|
-
##
|
10
|
-
# Allows the user to specify the path to a "dump" utility
|
11
|
-
# in case it cannot be auto-detected by Backup
|
12
|
-
# [DEPRECATED] - use each subclass' <utility_name>_utility method
|
13
|
-
attr_accessor :utility_path
|
14
|
-
|
15
9
|
##
|
16
10
|
# Creates a new instance of the MongoDB database object
|
17
11
|
# * Called using super(model) from subclasses *
|
@@ -32,6 +32,9 @@ module Backup
|
|
32
32
|
# Path to the mongodump utility (optional)
|
33
33
|
attr_accessor :mongodump_utility
|
34
34
|
|
35
|
+
attr_deprecate :utility_path, :version => '3.0.21',
|
36
|
+
:replacement => :mongodump_utility
|
37
|
+
|
35
38
|
##
|
36
39
|
# Path to the mongo utility (optional)
|
37
40
|
attr_accessor :mongo_utility
|
@@ -52,12 +55,6 @@ module Backup
|
|
52
55
|
|
53
56
|
instance_eval(&block) if block_given?
|
54
57
|
|
55
|
-
if @utility_path
|
56
|
-
Logger.warn "[DEPRECATED] " +
|
57
|
-
"Database::MongoDB#utility_path has been deprecated.\n" +
|
58
|
-
" Use Database::MongoDB#mongodump_utility instead."
|
59
|
-
@mongodump_utility ||= @utility_path
|
60
|
-
end
|
61
58
|
@mongodump_utility ||= utility(:mongodump)
|
62
59
|
@mongo_utility ||= utility(:mongo)
|
63
60
|
end
|
@@ -117,18 +114,37 @@ module Backup
|
|
117
114
|
def package!
|
118
115
|
return unless @model.compressor
|
119
116
|
|
117
|
+
pipeline = Pipeline.new
|
120
118
|
base_dir = File.dirname(@dump_path)
|
121
119
|
dump_dir = File.basename(@dump_path)
|
122
120
|
timestamp = Time.now.to_i.to_s[-5, 5]
|
123
121
|
outfile = @dump_path + '-' + timestamp + '.tar'
|
124
122
|
|
123
|
+
Logger.message(
|
124
|
+
"#{ database_name } started compressing and packaging:\n" +
|
125
|
+
" '#{ @dump_path }'"
|
126
|
+
)
|
127
|
+
|
128
|
+
pipeline << "#{ utility(:tar) } -cf - -C '#{ base_dir }' '#{ dump_dir }'"
|
125
129
|
@model.compressor.compress_with do |command, ext|
|
126
|
-
|
127
|
-
|
128
|
-
|
130
|
+
pipeline << command
|
131
|
+
outfile << ext
|
132
|
+
end
|
133
|
+
pipeline << "cat > #{ outfile }"
|
134
|
+
|
135
|
+
pipeline.run
|
136
|
+
if pipeline.success?
|
137
|
+
Logger.message(
|
138
|
+
"#{ database_name } completed compressing and packaging:\n" +
|
139
|
+
" '#{ outfile }'"
|
140
|
+
)
|
141
|
+
FileUtils.rm_rf(@dump_path)
|
142
|
+
else
|
143
|
+
raise Errors::Database::PipelineError,
|
144
|
+
"#{ database_name } Failed to create compressed dump package:\n" +
|
145
|
+
"'#{ outfile }'\n" +
|
146
|
+
pipeline.error_messages
|
129
147
|
end
|
130
|
-
|
131
|
-
FileUtils.rm_rf(@dump_path)
|
132
148
|
end
|
133
149
|
|
134
150
|
##
|
@@ -33,6 +33,9 @@ module Backup
|
|
33
33
|
# Path to mysqldump utility (optional)
|
34
34
|
attr_accessor :mysqldump_utility
|
35
35
|
|
36
|
+
attr_deprecate :utility_path, :version => '3.0.21',
|
37
|
+
:replacement => :mysqldump_utility
|
38
|
+
|
36
39
|
##
|
37
40
|
# Creates a new instance of the MySQL adapter object
|
38
41
|
def initialize(model, &block)
|
@@ -45,13 +48,6 @@ module Backup
|
|
45
48
|
instance_eval(&block) if block_given?
|
46
49
|
|
47
50
|
@name ||= :all
|
48
|
-
|
49
|
-
if @utility_path
|
50
|
-
Logger.warn "[DEPRECATED] " +
|
51
|
-
"Database::MySQL#utility_path has been deprecated.\n" +
|
52
|
-
" Use Database::MySQL#mysqldump_utility instead."
|
53
|
-
@mysqldump_utility ||= @utility_path
|
54
|
-
end
|
55
51
|
@mysqldump_utility ||= utility(:mysqldump)
|
56
52
|
end
|
57
53
|
|
@@ -61,18 +57,26 @@ module Backup
|
|
61
57
|
def perform!
|
62
58
|
super
|
63
59
|
|
60
|
+
pipeline = Pipeline.new
|
64
61
|
dump_ext = 'sql'
|
65
|
-
dump_cmd = "#{ mysqldump }"
|
66
62
|
|
63
|
+
pipeline << mysqldump
|
67
64
|
if @model.compressor
|
68
65
|
@model.compressor.compress_with do |command, ext|
|
69
|
-
|
66
|
+
pipeline << command
|
70
67
|
dump_ext << ext
|
71
68
|
end
|
72
69
|
end
|
73
|
-
|
74
|
-
|
75
|
-
run
|
70
|
+
pipeline << "cat > '#{ File.join(@dump_path, dump_filename) }.#{ dump_ext }'"
|
71
|
+
|
72
|
+
pipeline.run
|
73
|
+
if pipeline.success?
|
74
|
+
Logger.message "#{ database_name } Complete!"
|
75
|
+
else
|
76
|
+
raise Errors::Database::PipelineError,
|
77
|
+
"#{ database_name } Dump Failed!\n" +
|
78
|
+
pipeline.error_messages
|
79
|
+
end
|
76
80
|
end
|
77
81
|
|
78
82
|
private
|
@@ -137,8 +141,9 @@ module Backup
|
|
137
141
|
# during the dumping of the database
|
138
142
|
def tables_to_skip
|
139
143
|
skip_tables.map do |table|
|
140
|
-
|
141
|
-
|
144
|
+
table = (dump_all? || table['.']) ? table : "#{ name }.#{ table }"
|
145
|
+
"--ignore-table='#{ table }'"
|
146
|
+
end.join(' ')
|
142
147
|
end
|
143
148
|
|
144
149
|
##
|
@@ -32,6 +32,9 @@ module Backup
|
|
32
32
|
# Path to pg_dump utility (optional)
|
33
33
|
attr_accessor :pg_dump_utility
|
34
34
|
|
35
|
+
attr_deprecate :utility_path, :version => '3.0.21',
|
36
|
+
:replacement => :pg_dump_utility
|
37
|
+
|
35
38
|
##
|
36
39
|
# Creates a new instance of the PostgreSQL adapter object
|
37
40
|
# Sets the PGPASSWORD environment variable to the password
|
@@ -45,12 +48,6 @@ module Backup
|
|
45
48
|
|
46
49
|
instance_eval(&block) if block_given?
|
47
50
|
|
48
|
-
if @utility_path
|
49
|
-
Logger.warn "[DEPRECATED] " +
|
50
|
-
"Database::PostgreSQL#utility_path has been deprecated.\n" +
|
51
|
-
" Use Database::PostgreSQL#pg_dump_utility instead."
|
52
|
-
@pg_dump_utility ||= @utility_path
|
53
|
-
end
|
54
51
|
@pg_dump_utility ||= utility(:pg_dump)
|
55
52
|
end
|
56
53
|
|
@@ -60,18 +57,26 @@ module Backup
|
|
60
57
|
def perform!
|
61
58
|
super
|
62
59
|
|
60
|
+
pipeline = Pipeline.new
|
63
61
|
dump_ext = 'sql'
|
64
|
-
dump_cmd = "#{ pgdump }"
|
65
62
|
|
63
|
+
pipeline << pgdump
|
66
64
|
if @model.compressor
|
67
65
|
@model.compressor.compress_with do |command, ext|
|
68
|
-
|
66
|
+
pipeline << command
|
69
67
|
dump_ext << ext
|
70
68
|
end
|
71
69
|
end
|
72
|
-
|
73
|
-
|
74
|
-
run
|
70
|
+
pipeline << "cat > '#{ File.join(@dump_path, name) }.#{ dump_ext }'"
|
71
|
+
|
72
|
+
pipeline.run
|
73
|
+
if pipeline.success?
|
74
|
+
Logger.message "#{ database_name } Complete!"
|
75
|
+
else
|
76
|
+
raise Errors::Database::PipelineError,
|
77
|
+
"#{ database_name } Dump Failed!\n" +
|
78
|
+
pipeline.error_messages
|
79
|
+
end
|
75
80
|
end
|
76
81
|
|
77
82
|
##
|
@@ -12,16 +12,16 @@ module Backup
|
|
12
12
|
# Credentials for the specified database
|
13
13
|
attr_accessor :password
|
14
14
|
|
15
|
+
##
|
16
|
+
# Connectivity options
|
17
|
+
attr_accessor :host, :port, :socket
|
18
|
+
|
15
19
|
##
|
16
20
|
# Determines whether Backup should invoke the SAVE command through
|
17
21
|
# the 'redis-cli' utility to persist the most recent data before
|
18
22
|
# copying over the dump file
|
19
23
|
attr_accessor :invoke_save
|
20
24
|
|
21
|
-
##
|
22
|
-
# Connectivity options
|
23
|
-
attr_accessor :host, :port, :socket
|
24
|
-
|
25
25
|
##
|
26
26
|
# Additional "redis-cli" options
|
27
27
|
attr_accessor :additional_options
|
@@ -30,6 +30,9 @@ module Backup
|
|
30
30
|
# Path to the redis-cli utility (optional)
|
31
31
|
attr_accessor :redis_cli_utility
|
32
32
|
|
33
|
+
attr_deprecate :utility_path, :version => '3.0.21',
|
34
|
+
:replacement => :redis_cli_utility
|
35
|
+
|
33
36
|
##
|
34
37
|
# Creates a new instance of the Redis database object
|
35
38
|
def initialize(model, &block)
|
@@ -40,13 +43,6 @@ module Backup
|
|
40
43
|
instance_eval(&block) if block_given?
|
41
44
|
|
42
45
|
@name ||= 'dump'
|
43
|
-
|
44
|
-
if @utility_path
|
45
|
-
Logger.warn "[DEPRECATED] " +
|
46
|
-
"Database::Redis#utility_path has been deprecated.\n" +
|
47
|
-
" Use Database::Redis#redis_cli_utility instead."
|
48
|
-
@redis_cli_utility ||= @utility_path
|
49
|
-
end
|
50
46
|
@redis_cli_utility ||= utility('redis-cli')
|
51
47
|
end
|
52
48
|
|
data/lib/backup/database/riak.rb
CHANGED
@@ -20,6 +20,9 @@ module Backup
|
|
20
20
|
# Path to riak-admin utility (optional)
|
21
21
|
attr_accessor :riak_admin_utility
|
22
22
|
|
23
|
+
attr_deprecate :utility_path, :version => '3.0.21',
|
24
|
+
:replacement => :riak_admin_utility
|
25
|
+
|
23
26
|
##
|
24
27
|
# Creates a new instance of the Riak adapter object
|
25
28
|
def initialize(model, &block)
|
@@ -27,12 +30,6 @@ module Backup
|
|
27
30
|
|
28
31
|
instance_eval(&block) if block_given?
|
29
32
|
|
30
|
-
if @utility_path
|
31
|
-
Logger.warn "[DEPRECATED] " +
|
32
|
-
"Database::Riak#utility_path has been deprecated.\n" +
|
33
|
-
" Use Database::Riak#riak_admin_utility instead."
|
34
|
-
@riak_admin_utility ||= @utility_path
|
35
|
-
end
|
36
33
|
@riak_admin_utility ||= utility('riak-admin')
|
37
34
|
end
|
38
35
|
|
data/lib/backup/dependency.rb
CHANGED
@@ -17,13 +17,13 @@ module Backup
|
|
17
17
|
{
|
18
18
|
'fog' => {
|
19
19
|
:require => 'fog',
|
20
|
-
:version => '
|
20
|
+
:version => '~> 1.1.0',
|
21
21
|
:for => 'Amazon S3, Rackspace Cloud Files (S3, CloudFiles Storages)'
|
22
22
|
},
|
23
23
|
|
24
24
|
'dropbox-sdk' => {
|
25
25
|
:require => 'dropbox_sdk',
|
26
|
-
:version => '~> 1.
|
26
|
+
:version => '~> 1.2.0',
|
27
27
|
:for => 'Dropbox Web Service (Dropbox Storage)'
|
28
28
|
},
|
29
29
|
|
@@ -41,13 +41,13 @@ module Backup
|
|
41
41
|
|
42
42
|
'net-ssh' => {
|
43
43
|
:require => 'net/ssh',
|
44
|
-
:version => '~> 2.
|
44
|
+
:version => '~> 2.3.0',
|
45
45
|
:for => 'SSH Protocol (SSH Storage)'
|
46
46
|
},
|
47
47
|
|
48
48
|
'mail' => {
|
49
49
|
:require => 'mail',
|
50
|
-
:version => '
|
50
|
+
:version => '~> 2.4.0',
|
51
51
|
:for => 'Sending Emails (Mail Notifier)'
|
52
52
|
},
|
53
53
|
|
@@ -59,16 +59,10 @@ module Backup
|
|
59
59
|
|
60
60
|
'httparty' => {
|
61
61
|
:require => 'httparty',
|
62
|
-
:version => '~> 0.
|
62
|
+
:version => '~> 0.8.1',
|
63
63
|
:for => 'Sending Http Updates'
|
64
64
|
},
|
65
65
|
|
66
|
-
'json' => {
|
67
|
-
:require => 'json',
|
68
|
-
:version => '~> 1.5.1',
|
69
|
-
:for => 'Parsing JSON for HTTParty'
|
70
|
-
},
|
71
|
-
|
72
66
|
'prowler' => {
|
73
67
|
:require => 'prowler',
|
74
68
|
:version => '>= 1.3.1',
|
data/lib/backup/model.rb
CHANGED
@@ -125,16 +125,25 @@ module Backup
|
|
125
125
|
# methods to use during the backup process
|
126
126
|
def sync_with(name, &block)
|
127
127
|
##
|
128
|
-
# Warn user of DSL
|
129
|
-
|
128
|
+
# Warn user of DSL changes
|
129
|
+
case name.to_s
|
130
|
+
when 'Backup::Config::RSync'
|
130
131
|
Logger.warn Errors::ConfigError.new(<<-EOS)
|
131
132
|
Configuration Update Needed for Syncer::RSync
|
132
133
|
The RSync Syncer has been split into three separate modules:
|
133
134
|
RSync::Local, RSync::Push and RSync::Pull
|
134
|
-
Please update your configuration
|
135
|
-
|
135
|
+
Please update your configuration.
|
136
|
+
i.e. 'sync_with RSync' is now 'sync_with RSync::Push'
|
136
137
|
EOS
|
137
|
-
name =
|
138
|
+
name = 'RSync::Push'
|
139
|
+
when /(Backup::Config::S3|Backup::Config::CloudFiles)/
|
140
|
+
syncer = $1.split('::')[2]
|
141
|
+
Logger.warn Errors::ConfigError.new(<<-EOS)
|
142
|
+
Configuration Update Needed for '#{ syncer }' Syncer.
|
143
|
+
This Syncer is now referenced as Cloud::#{ syncer }
|
144
|
+
i.e. 'sync_with #{ syncer }' is now 'sync_with Cloud::#{ syncer }'
|
145
|
+
EOS
|
146
|
+
name = "Cloud::#{ syncer }"
|
138
147
|
end
|
139
148
|
@syncers << get_class_from_scope(Syncer, name).new(&block)
|
140
149
|
end
|
@@ -1,15 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
##
|
4
|
-
# If the Ruby version of this process is 1.8.x or less
|
5
|
-
# then use the JSON gem. Otherwise if the current process is running
|
6
|
-
# Ruby 1.9.x or later then it is built in and we can load it from the Ruby core lib
|
7
|
-
if RUBY_VERSION < '1.9.0'
|
8
|
-
Backup::Dependency.load('json')
|
9
|
-
else
|
10
|
-
require 'json'
|
11
|
-
end
|
12
|
-
|
13
3
|
##
|
14
4
|
# Load the HTTParty library from the gem
|
15
5
|
Backup::Dependency.load('httparty')
|
@@ -139,12 +129,9 @@ module Backup
|
|
139
129
|
# This method builds up a POST request with the necessary params (serialized to JSON format)
|
140
130
|
# and sends it to the Campfire service in order to submit the message
|
141
131
|
def send_message(message, type = 'Textmessage')
|
142
|
-
post 'speak', :body =>
|
143
|
-
:message => {
|
144
|
-
|
145
|
-
:type => type
|
146
|
-
}
|
147
|
-
}.to_json
|
132
|
+
post 'speak', :body => MultiJson.encode(
|
133
|
+
{ :message => { :body => message, :type => type } }
|
134
|
+
)
|
148
135
|
end
|
149
136
|
|
150
137
|
##
|
data/lib/backup/notifier/mail.rb
CHANGED
data/lib/backup/packager.rb
CHANGED
@@ -11,17 +11,25 @@ module Backup
|
|
11
11
|
@package = model.package
|
12
12
|
@encryptor = model.encryptor
|
13
13
|
@splitter = model.splitter
|
14
|
+
@pipeline = Pipeline.new
|
14
15
|
|
15
16
|
Logger.message "Packaging the backup files..."
|
16
17
|
procedure.call
|
17
|
-
|
18
|
+
|
19
|
+
if @pipeline.success?
|
20
|
+
Logger.message "Packaging Complete!"
|
21
|
+
else
|
22
|
+
raise Errors::Packager::PipelineError,
|
23
|
+
"Failed to Create Backup Package\n" +
|
24
|
+
@pipeline.error_messages
|
25
|
+
end
|
18
26
|
end
|
19
27
|
|
20
28
|
private
|
21
29
|
|
22
30
|
##
|
23
|
-
# Builds a chain of nested Procs which
|
24
|
-
# the final command to package the backup.
|
31
|
+
# Builds a chain of nested Procs which adds each command to a Pipeline
|
32
|
+
# needed to package the final command to package the backup.
|
25
33
|
# This is done so that the Encryptor and Splitter have the ability
|
26
34
|
# to perform actions before and after the final command is executed.
|
27
35
|
# No Encryptors currently utilize this, however the Splitter does.
|
@@ -31,20 +39,21 @@ module Backup
|
|
31
39
|
##
|
32
40
|
# Initial `tar` command to package the temporary backup folder.
|
33
41
|
# The command's output will then be either piped to the Encryptor
|
34
|
-
# or the Splitter (if no Encryptor), or
|
42
|
+
# or the Splitter (if no Encryptor), or through `cat` into the final
|
35
43
|
# output file if neither are configured.
|
36
|
-
@
|
44
|
+
@pipeline << "#{ utility(:tar) } -cf - " +
|
37
45
|
"-C '#{ Config.tmp_path }' '#{ @package.trigger }'"
|
38
46
|
|
39
47
|
##
|
40
48
|
# If an Encryptor was configured, it will be called first
|
41
|
-
# to
|
42
|
-
#
|
43
|
-
#
|
49
|
+
# to add the encryption utility command to be piped through,
|
50
|
+
# and amend the final package extension.
|
51
|
+
# It's output will then be either piped into a Splitter,
|
52
|
+
# or through `cat` into the final output file.
|
44
53
|
if @encryptor
|
45
54
|
stack << lambda do
|
46
55
|
@encryptor.encrypt_with do |command, ext|
|
47
|
-
@
|
56
|
+
@pipeline << command
|
48
57
|
@package.extension << ext
|
49
58
|
stack.shift.call
|
50
59
|
end
|
@@ -52,35 +61,36 @@ module Backup
|
|
52
61
|
end
|
53
62
|
|
54
63
|
##
|
55
|
-
# If a Splitter was configured, the command will be
|
56
|
-
# the
|
57
|
-
#
|
58
|
-
#
|
64
|
+
# If a Splitter was configured, the `split` utility command will be
|
65
|
+
# added to the Pipeline to split the final output into multiple files.
|
66
|
+
# Once the Proc executing the Pipeline has completed and returns back
|
67
|
+
# to the Splitter, it will check the final output files to determine
|
68
|
+
# if the backup was indeed split.
|
59
69
|
# If so, it will set the package's chunk_suffixes. If not, it will
|
60
70
|
# remove the '-aa' suffix from the only file created by `split`.
|
61
71
|
#
|
62
|
-
# If no Splitter was configured, the
|
63
|
-
#
|
72
|
+
# If no Splitter was configured, the final file output will be
|
73
|
+
# piped through `cat` into the final output file.
|
64
74
|
if @splitter
|
65
75
|
stack << lambda do
|
66
76
|
@splitter.split_with do |command|
|
67
|
-
@
|
77
|
+
@pipeline << command
|
68
78
|
stack.shift.call
|
69
79
|
end
|
70
80
|
end
|
71
81
|
else
|
72
82
|
stack << lambda do
|
73
83
|
outfile = File.join(Config.tmp_path, @package.basename)
|
74
|
-
@
|
84
|
+
@pipeline << "cat > #{ outfile }"
|
75
85
|
stack.shift.call
|
76
86
|
end
|
77
87
|
end
|
78
88
|
|
79
89
|
##
|
80
|
-
# Last Proc to be called runs the
|
90
|
+
# Last Proc to be called runs the Pipeline the procedure built.
|
81
91
|
# Once complete, the call stack will unwind back through the
|
82
92
|
# preceeding Procs in the stack (if any)
|
83
|
-
stack << lambda { run
|
93
|
+
stack << lambda { @pipeline.run }
|
84
94
|
|
85
95
|
stack.shift
|
86
96
|
end
|