backup 3.0.23 → 3.0.24

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.
Files changed (197) hide show
  1. data/Gemfile.lock +42 -45
  2. data/Guardfile +7 -4
  3. data/README.md +10 -7
  4. data/backup.gemspec +2 -2
  5. data/lib/backup.rb +27 -97
  6. data/lib/backup/archive.rb +14 -6
  7. data/lib/backup/cli/helpers.rb +52 -49
  8. data/lib/backup/cli/utility.rb +9 -1
  9. data/lib/backup/compressor/base.rb +10 -4
  10. data/lib/backup/compressor/bzip2.rb +22 -26
  11. data/lib/backup/compressor/custom.rb +53 -0
  12. data/lib/backup/compressor/gzip.rb +22 -23
  13. data/lib/backup/compressor/lzma.rb +15 -13
  14. data/lib/backup/compressor/pbzip2.rb +20 -17
  15. data/lib/backup/config.rb +6 -3
  16. data/lib/backup/configuration.rb +33 -0
  17. data/lib/backup/configuration/helpers.rb +114 -28
  18. data/lib/backup/configuration/store.rb +24 -0
  19. data/lib/backup/database/base.rb +0 -6
  20. data/lib/backup/database/mongodb.rb +27 -11
  21. data/lib/backup/database/mysql.rb +19 -14
  22. data/lib/backup/database/postgresql.rb +16 -11
  23. data/lib/backup/database/redis.rb +7 -11
  24. data/lib/backup/database/riak.rb +3 -6
  25. data/lib/backup/dependency.rb +5 -11
  26. data/lib/backup/model.rb +14 -5
  27. data/lib/backup/notifier/campfire.rb +3 -16
  28. data/lib/backup/notifier/hipchat.rb +1 -7
  29. data/lib/backup/notifier/mail.rb +1 -1
  30. data/lib/backup/packager.rb +29 -19
  31. data/lib/backup/pipeline.rb +110 -0
  32. data/lib/backup/storage/dropbox.rb +4 -7
  33. data/lib/backup/syncer/base.rb +8 -4
  34. data/lib/backup/syncer/cloud/base.rb +247 -0
  35. data/lib/backup/syncer/cloud/cloud_files.rb +78 -0
  36. data/lib/backup/syncer/cloud/s3.rb +68 -0
  37. data/lib/backup/syncer/rsync/base.rb +1 -4
  38. data/lib/backup/syncer/rsync/local.rb +9 -5
  39. data/lib/backup/syncer/rsync/pull.rb +1 -1
  40. data/lib/backup/syncer/rsync/push.rb +10 -5
  41. data/lib/backup/version.rb +1 -1
  42. data/spec-live/.gitignore +6 -0
  43. data/spec-live/README +7 -0
  44. data/spec-live/backups/config.rb +153 -0
  45. data/spec-live/backups/config.yml.template +43 -0
  46. data/spec-live/compressor/custom_spec.rb +30 -0
  47. data/spec-live/compressor/gzip_spec.rb +30 -0
  48. data/spec-live/notifier/mail_spec.rb +85 -0
  49. data/spec-live/spec_helper.rb +85 -0
  50. data/spec-live/storage/dropbox_spec.rb +151 -0
  51. data/spec-live/storage/local_spec.rb +83 -0
  52. data/spec-live/storage/scp_spec.rb +193 -0
  53. data/spec-live/syncer/cloud/s3_spec.rb +124 -0
  54. data/spec/archive_spec.rb +86 -31
  55. data/spec/cleaner_spec.rb +8 -0
  56. data/spec/cli/helpers_spec.rb +200 -75
  57. data/spec/cli/utility_spec.rb +11 -3
  58. data/spec/compressor/base_spec.rb +31 -10
  59. data/spec/compressor/bzip2_spec.rb +212 -57
  60. data/spec/compressor/custom_spec.rb +106 -0
  61. data/spec/compressor/gzip_spec.rb +212 -57
  62. data/spec/compressor/lzma_spec.rb +75 -35
  63. data/spec/compressor/pbzip2_spec.rb +93 -52
  64. data/spec/configuration/helpers_spec.rb +406 -0
  65. data/spec/configuration/store_spec.rb +39 -0
  66. data/spec/configuration_spec.rb +62 -0
  67. data/spec/database/base_spec.rb +19 -10
  68. data/spec/database/mongodb_spec.rb +195 -70
  69. data/spec/database/mysql_spec.rb +183 -64
  70. data/spec/database/postgresql_spec.rb +167 -53
  71. data/spec/database/redis_spec.rb +121 -46
  72. data/spec/database/riak_spec.rb +96 -27
  73. data/spec/dependency_spec.rb +2 -0
  74. data/spec/encryptor/base_spec.rb +10 -0
  75. data/spec/encryptor/gpg_spec.rb +29 -13
  76. data/spec/encryptor/open_ssl_spec.rb +40 -21
  77. data/spec/logger_spec.rb +4 -0
  78. data/spec/model_spec.rb +19 -2
  79. data/spec/notifier/base_spec.rb +32 -17
  80. data/spec/notifier/campfire_spec.rb +63 -45
  81. data/spec/notifier/hipchat_spec.rb +79 -56
  82. data/spec/notifier/mail_spec.rb +82 -46
  83. data/spec/notifier/prowl_spec.rb +53 -32
  84. data/spec/notifier/twitter_spec.rb +62 -41
  85. data/spec/packager_spec.rb +95 -36
  86. data/spec/pipeline_spec.rb +259 -0
  87. data/spec/spec_helper.rb +6 -5
  88. data/spec/storage/base_spec.rb +61 -41
  89. data/spec/storage/cloudfiles_spec.rb +69 -45
  90. data/spec/storage/dropbox_spec.rb +158 -36
  91. data/spec/storage/ftp_spec.rb +69 -45
  92. data/spec/storage/local_spec.rb +47 -23
  93. data/spec/storage/ninefold_spec.rb +55 -31
  94. data/spec/storage/rsync_spec.rb +67 -50
  95. data/spec/storage/s3_spec.rb +65 -41
  96. data/spec/storage/scp_spec.rb +65 -41
  97. data/spec/storage/sftp_spec.rb +65 -41
  98. data/spec/syncer/base_spec.rb +91 -4
  99. data/spec/syncer/cloud/base_spec.rb +511 -0
  100. data/spec/syncer/cloud/cloud_files_spec.rb +181 -0
  101. data/spec/syncer/cloud/s3_spec.rb +174 -0
  102. data/spec/syncer/rsync/base_spec.rb +46 -66
  103. data/spec/syncer/rsync/local_spec.rb +55 -26
  104. data/spec/syncer/rsync/pull_spec.rb +15 -4
  105. data/spec/syncer/rsync/push_spec.rb +59 -52
  106. data/templates/cli/utility/compressor/bzip2 +1 -4
  107. data/templates/cli/utility/compressor/custom +11 -0
  108. data/templates/cli/utility/compressor/gzip +1 -4
  109. data/templates/cli/utility/compressor/lzma +3 -0
  110. data/templates/cli/utility/compressor/pbzip2 +3 -0
  111. data/templates/cli/utility/database/mysql +4 -1
  112. data/templates/cli/utility/syncer/cloud_files +17 -19
  113. data/templates/cli/utility/syncer/s3 +18 -20
  114. metadata +38 -92
  115. data/lib/backup/configuration/base.rb +0 -15
  116. data/lib/backup/configuration/compressor/base.rb +0 -9
  117. data/lib/backup/configuration/compressor/bzip2.rb +0 -23
  118. data/lib/backup/configuration/compressor/gzip.rb +0 -23
  119. data/lib/backup/configuration/compressor/lzma.rb +0 -23
  120. data/lib/backup/configuration/compressor/pbzip2.rb +0 -28
  121. data/lib/backup/configuration/database/base.rb +0 -19
  122. data/lib/backup/configuration/database/mongodb.rb +0 -49
  123. data/lib/backup/configuration/database/mysql.rb +0 -42
  124. data/lib/backup/configuration/database/postgresql.rb +0 -41
  125. data/lib/backup/configuration/database/redis.rb +0 -39
  126. data/lib/backup/configuration/database/riak.rb +0 -29
  127. data/lib/backup/configuration/encryptor/base.rb +0 -9
  128. data/lib/backup/configuration/encryptor/gpg.rb +0 -17
  129. data/lib/backup/configuration/encryptor/open_ssl.rb +0 -32
  130. data/lib/backup/configuration/notifier/base.rb +0 -28
  131. data/lib/backup/configuration/notifier/campfire.rb +0 -25
  132. data/lib/backup/configuration/notifier/hipchat.rb +0 -41
  133. data/lib/backup/configuration/notifier/mail.rb +0 -112
  134. data/lib/backup/configuration/notifier/presently.rb +0 -25
  135. data/lib/backup/configuration/notifier/prowl.rb +0 -23
  136. data/lib/backup/configuration/notifier/twitter.rb +0 -21
  137. data/lib/backup/configuration/storage/base.rb +0 -18
  138. data/lib/backup/configuration/storage/cloudfiles.rb +0 -25
  139. data/lib/backup/configuration/storage/dropbox.rb +0 -58
  140. data/lib/backup/configuration/storage/ftp.rb +0 -29
  141. data/lib/backup/configuration/storage/local.rb +0 -17
  142. data/lib/backup/configuration/storage/ninefold.rb +0 -20
  143. data/lib/backup/configuration/storage/rsync.rb +0 -29
  144. data/lib/backup/configuration/storage/s3.rb +0 -25
  145. data/lib/backup/configuration/storage/scp.rb +0 -25
  146. data/lib/backup/configuration/storage/sftp.rb +0 -25
  147. data/lib/backup/configuration/syncer/base.rb +0 -10
  148. data/lib/backup/configuration/syncer/cloud.rb +0 -23
  149. data/lib/backup/configuration/syncer/cloud_files.rb +0 -30
  150. data/lib/backup/configuration/syncer/rsync/base.rb +0 -28
  151. data/lib/backup/configuration/syncer/rsync/local.rb +0 -11
  152. data/lib/backup/configuration/syncer/rsync/pull.rb +0 -11
  153. data/lib/backup/configuration/syncer/rsync/push.rb +0 -31
  154. data/lib/backup/configuration/syncer/s3.rb +0 -23
  155. data/lib/backup/notifier/presently.rb +0 -88
  156. data/lib/backup/syncer/cloud.rb +0 -187
  157. data/lib/backup/syncer/cloud_files.rb +0 -56
  158. data/lib/backup/syncer/s3.rb +0 -47
  159. data/spec/configuration/base_spec.rb +0 -35
  160. data/spec/configuration/compressor/bzip2_spec.rb +0 -29
  161. data/spec/configuration/compressor/gzip_spec.rb +0 -29
  162. data/spec/configuration/compressor/lzma_spec.rb +0 -29
  163. data/spec/configuration/compressor/pbzip2_spec.rb +0 -32
  164. data/spec/configuration/database/base_spec.rb +0 -17
  165. data/spec/configuration/database/mongodb_spec.rb +0 -56
  166. data/spec/configuration/database/mysql_spec.rb +0 -53
  167. data/spec/configuration/database/postgresql_spec.rb +0 -53
  168. data/spec/configuration/database/redis_spec.rb +0 -50
  169. data/spec/configuration/database/riak_spec.rb +0 -35
  170. data/spec/configuration/encryptor/gpg_spec.rb +0 -26
  171. data/spec/configuration/encryptor/open_ssl_spec.rb +0 -35
  172. data/spec/configuration/notifier/base_spec.rb +0 -32
  173. data/spec/configuration/notifier/campfire_spec.rb +0 -32
  174. data/spec/configuration/notifier/hipchat_spec.rb +0 -44
  175. data/spec/configuration/notifier/mail_spec.rb +0 -71
  176. data/spec/configuration/notifier/presently_spec.rb +0 -35
  177. data/spec/configuration/notifier/prowl_spec.rb +0 -29
  178. data/spec/configuration/notifier/twitter_spec.rb +0 -35
  179. data/spec/configuration/storage/cloudfiles_spec.rb +0 -41
  180. data/spec/configuration/storage/dropbox_spec.rb +0 -38
  181. data/spec/configuration/storage/ftp_spec.rb +0 -44
  182. data/spec/configuration/storage/local_spec.rb +0 -29
  183. data/spec/configuration/storage/ninefold_spec.rb +0 -32
  184. data/spec/configuration/storage/rsync_spec.rb +0 -41
  185. data/spec/configuration/storage/s3_spec.rb +0 -38
  186. data/spec/configuration/storage/scp_spec.rb +0 -41
  187. data/spec/configuration/storage/sftp_spec.rb +0 -41
  188. data/spec/configuration/syncer/cloud_files_spec.rb +0 -44
  189. data/spec/configuration/syncer/rsync/base_spec.rb +0 -33
  190. data/spec/configuration/syncer/rsync/local_spec.rb +0 -10
  191. data/spec/configuration/syncer/rsync/pull_spec.rb +0 -10
  192. data/spec/configuration/syncer/rsync/push_spec.rb +0 -43
  193. data/spec/configuration/syncer/s3_spec.rb +0 -38
  194. data/spec/notifier/presently_spec.rb +0 -181
  195. data/spec/syncer/cloud_files_spec.rb +0 -192
  196. data/spec/syncer/s3_spec.rb +0 -192
  197. 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
@@ -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
- run("#{ utility(:tar) } -cf - " +
127
- "-C '#{ base_dir }' '#{ dump_dir }'" +
128
- " | #{ command } > #{ outfile + ext }")
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
- dump_cmd << " | #{command}"
66
+ pipeline << command
70
67
  dump_ext << ext
71
68
  end
72
69
  end
73
-
74
- dump_cmd << " > '#{ File.join(@dump_path, dump_filename) }.#{ dump_ext }'"
75
- run(dump_cmd)
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
- "--ignore-table='#{name}.#{table}'"
141
- end.join(' ') unless dump_all?
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
- dump_cmd << " | #{command}"
66
+ pipeline << command
69
67
  dump_ext << ext
70
68
  end
71
69
  end
72
-
73
- dump_cmd << " > '#{ File.join(@dump_path, name) }.#{ dump_ext }'"
74
- run(dump_cmd)
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
 
@@ -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
 
@@ -17,13 +17,13 @@ module Backup
17
17
  {
18
18
  'fog' => {
19
19
  :require => 'fog',
20
- :version => '>= 0.11.0',
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.1.0',
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.1.4',
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 => '>= 2.4.0',
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.7.4',
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 change from 'RSync' to 'RSync::Local'
129
- if name.to_s == 'Backup::Config::RSync'
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 for your local RSync Syncer
135
- from 'sync_with RSync do ...' to 'sync_with RSync::Local do ...'
135
+ Please update your configuration.
136
+ i.e. 'sync_with RSync' is now 'sync_with RSync::Push'
136
137
  EOS
137
- name = Backup::Config::RSync::Local
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
- :body => message,
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
  ##
@@ -1,12 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- if RUBY_VERSION < '1.9.0'
4
- Backup::Dependency.load('json')
5
- else
6
- require 'json'
7
- end
8
-
9
- # Load HTTParty
3
+ # Load the HipChat library from the gem
10
4
  Backup::Dependency.load('hipchat')
11
5
 
12
6
  module Backup
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  ##
4
- # Only load the Mail gem and Erb library when using Mail notifications
4
+ # Only load the Mail gem when using Mail notifications
5
5
  Backup::Dependency.load('mail')
6
6
 
7
7
  module Backup
@@ -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
- Logger.message "Packaging Complete!"
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 assemble and execute
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 redirected into the final
42
+ # or the Splitter (if no Encryptor), or through `cat` into the final
35
43
  # output file if neither are configured.
36
- @package_command = "#{ utility(:tar) } -cf - " +
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 amend the command to be piped through the encryption utility.
42
- # It's output will then be either piped into a Splitter, or sent
43
- # directly to the final output file.
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
- @package_command << " | #{command}"
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 piped through
56
- # the `split` command. Once the Proc executing the final command
57
- # has completed and returns back to the Splitter, it will check the
58
- # final output files to determine if the backup was indeed split.
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 command output will be
63
- # redirected directly into the final output file.
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
- @package_command << " | #{command}"
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
- @package_command << " > #{ outfile }"
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 command the procedure built.
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(@package_command) }
93
+ stack << lambda { @pipeline.run }
84
94
 
85
95
  stack.shift
86
96
  end