backup 3.0.23 → 3.0.24

Sign up to get free protection for your applications and to get access to all the features.
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,68 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Syncer
5
+ module Cloud
6
+ class S3 < Base
7
+
8
+ ##
9
+ # Amazon Simple Storage Service (S3) Credentials
10
+ attr_accessor :access_key_id, :secret_access_key
11
+
12
+ ##
13
+ # The S3 bucket to store files to
14
+ attr_accessor :bucket
15
+
16
+ ##
17
+ # The AWS region of the specified S3 bucket
18
+ attr_accessor :region
19
+
20
+ ##
21
+ # Instantiates a new Cloud::S3 Syncer.
22
+ #
23
+ # Pre-configured defaults specified in
24
+ # Configuration::Syncer::Cloud::S3
25
+ # are set via a super() call to Cloud::Base,
26
+ # which in turn will invoke Syncer::Base.
27
+ #
28
+ # Once pre-configured defaults and Cloud specific defaults are set,
29
+ # the block from the user's configuration file is evaluated.
30
+ def initialize(&block)
31
+ super
32
+
33
+ instance_eval(&block) if block_given?
34
+ @path = path.sub(/^\//, '')
35
+ end
36
+
37
+ private
38
+
39
+ ##
40
+ # Established and creates a new Fog storage object for S3.
41
+ def connection
42
+ @connection ||= Fog::Storage.new(
43
+ :provider => provider,
44
+ :aws_access_key_id => access_key_id,
45
+ :aws_secret_access_key => secret_access_key,
46
+ :region => region
47
+ )
48
+ end
49
+
50
+ ##
51
+ # Creates a new @repository_object (bucket).
52
+ # Fetches it from S3 if it already exists,
53
+ # otherwise it will create it first and fetch use that instead.
54
+ def repository_object
55
+ @repository_object ||= connection.directories.get(bucket) ||
56
+ connection.directories.create(:key => bucket, :location => region)
57
+ end
58
+
59
+ ##
60
+ # This is the provider that Fog uses for the Cloud Files
61
+ def provider
62
+ "AWS"
63
+ end
64
+
65
+ end # Class S3 < Base
66
+ end # module Cloud
67
+ end
68
+ end
@@ -12,11 +12,8 @@ module Backup
12
12
  # Instantiates a new RSync Syncer object
13
13
  # and sets the default configuration
14
14
  def initialize
15
- load_defaults!
15
+ super
16
16
 
17
- @path ||= 'backups'
18
- @directories = Array.new
19
- @mirror ||= false
20
17
  @additional_options ||= Array.new
21
18
  end
22
19
 
@@ -6,11 +6,15 @@ module Backup
6
6
  class Local < Base
7
7
 
8
8
  ##
9
- # Instantiates a new RSync::Local Syncer object.
10
- # Default configuration values and any specified in
11
- # Backup::Configuration::Syncer::RSync::Local are set from Base.
12
- # The user's configuration file is then evaluated to overwrite
13
- # these values or provide additional configuration.
9
+ # Instantiates a new RSync::Local Syncer.
10
+ #
11
+ # Pre-configured defaults specified in
12
+ # Configuration::Syncer::RSync::Local
13
+ # are set via a super() call to RSync::Base,
14
+ # which in turn will invoke Syncer::Base.
15
+ #
16
+ # Once pre-configured defaults and RSync specific defaults are set,
17
+ # the block from the user's configuration file is evaluated.
14
18
  def initialize(&block)
15
19
  super
16
20
 
@@ -27,7 +27,7 @@ module Backup
27
27
  private
28
28
 
29
29
  ##
30
- # Return expanded @path
30
+ # Return expanded @path, since this path is local
31
31
  def dest_path
32
32
  @dest_path ||= File.expand_path(@path)
33
33
  end
@@ -22,11 +22,16 @@ module Backup
22
22
  attr_accessor :compress
23
23
 
24
24
  ##
25
- # Instantiates a new RSync::Push or RSync::Pull Syncer object.
26
- # Default configuration values and any specified in
27
- # Backup::Configuration::Syncer::RSync::[Push/Pull] are set from Base.
28
- # The user's configuration file is then evaluated to overwrite
29
- # these values or provide additional configuration.
25
+ # Instantiates a new RSync::Push or RSync::Pull Syncer.
26
+ #
27
+ # Pre-configured defaults specified in
28
+ # Configuration::Syncer::RSync::Push or
29
+ # Configuration::Syncer::RSync::Pull
30
+ # are set via a super() call to RSync::Base,
31
+ # which in turn will invoke Syncer::Base.
32
+ #
33
+ # Once pre-configured defaults and RSync specific defaults are set,
34
+ # the block from the user's configuration file is evaluated.
30
35
  def initialize(&block)
31
36
  super
32
37
 
@@ -13,7 +13,7 @@ module Backup
13
13
  # Defines the minor version
14
14
  # PATCH:
15
15
  # Defines the patch version
16
- MAJOR, MINOR, PATCH = 3, 0, 23
16
+ MAJOR, MINOR, PATCH = 3, 0, 24
17
17
 
18
18
  ##
19
19
  # Returns the major version ( big release based off of multiple minor releases )
@@ -0,0 +1,6 @@
1
+ backups/config.yml
2
+ backups/data
3
+ backups/log
4
+ backups/.cache
5
+ backups/.tmp
6
+ tmp/
data/spec-live/README ADDED
@@ -0,0 +1,7 @@
1
+ == spec-live ==
2
+
3
+ This folder contains "Live" specs which test various features against
4
+ the actual filesystem and/or real storage service accounts.
5
+
6
+ These are only intended to be used by developers.
7
+ Use at your own risk :)
@@ -0,0 +1,153 @@
1
+
2
+ ##
3
+ # Archive Job
4
+ archive_job = lambda do |archive|
5
+ archive.add File.expand_path('../../../lib/backup', __FILE__)
6
+ archive.exclude File.expand_path('../../../lib/backup/storage', __FILE__)
7
+ end
8
+
9
+ ##
10
+ # Configuration
11
+
12
+ Backup::Storage::Local.defaults do |storage|
13
+ storage.path = Backup::SpecLive::TMP_PATH
14
+ storage.keep = 2
15
+ end
16
+
17
+ # SSH operations can be tested against 'localhost'
18
+ # To do this, in the config.yml file:
19
+ # - set username/password for your current user
20
+ # - set ip to 'localhost'
21
+ # Although optional, it's recommended you set the 'path'
22
+ # to the same path as Backup::SpecLive::TMP_PATH
23
+ # i.e. '/absolute/path/to/spec-live/tmp'
24
+ # This way, cleaning the "remote path" can be skipped.
25
+ Backup::Storage::SCP.defaults do |storage|
26
+ opts = SpecLive::CONFIG['storage']['scp']
27
+
28
+ storage.username = opts['username']
29
+ storage.password = opts['password']
30
+ storage.ip = opts['ip']
31
+ storage.port = opts['port']
32
+ storage.path = opts['path']
33
+ storage.keep = 2
34
+ end
35
+
36
+ Backup::Storage::Dropbox.defaults do |storage|
37
+ opts = SpecLive::CONFIG['storage']['dropbox']
38
+
39
+ storage.api_key = opts['api_key']
40
+ storage.api_secret = opts['api_secret']
41
+ storage.access_type = opts['access_type']
42
+ storage.path = opts['path']
43
+ storage.keep = 2
44
+ end
45
+
46
+ Backup::Notifier::Mail.defaults do |notifier|
47
+ opts = SpecLive::CONFIG['notifier']['mail']
48
+
49
+ notifier.on_success = true
50
+ notifier.on_warning = true
51
+ notifier.on_failure = true
52
+
53
+ notifier.delivery_method = opts['delivery_method']
54
+ notifier.from = opts['from']
55
+ notifier.to = opts['to']
56
+ notifier.address = opts['address']
57
+ notifier.port = opts['port'] || 587
58
+ notifier.domain = opts['domain']
59
+ notifier.user_name = opts['user_name']
60
+ notifier.password = opts['password']
61
+ notifier.authentication = opts['authentication'] || 'plain'
62
+ notifier.enable_starttls_auto = opts['enable_starttls_auto'] || true
63
+ notifier.sendmail = opts['sendmail']
64
+ notifier.sendmail_args = opts['sendmail_args']
65
+ notifier.mail_folder = Backup::SpecLive::TMP_PATH
66
+ end
67
+
68
+ Backup::Syncer::Cloud::S3.defaults do |s3|
69
+ opts = SpecLive::CONFIG['syncer']['cloud']['s3']
70
+
71
+ s3.access_key_id = opts['access_key_id']
72
+ s3.secret_access_key = opts['secret_access_key']
73
+ s3.bucket = opts['bucket']
74
+ s3.region = opts['region']
75
+ s3.mirror = true
76
+ end
77
+
78
+ ##
79
+ # Models
80
+
81
+ Backup::Model.new(:archive_local, 'test_label') do
82
+ archive :test_archive, &archive_job
83
+ store_with Local
84
+ end
85
+
86
+ Backup::Model.new(:archive_scp, 'test_label') do
87
+ archive :test_archive, &archive_job
88
+ store_with SCP
89
+ end
90
+
91
+ # To initialize the Dropbox session cache, run manually first using:
92
+ # VERBOSE=1 rspec spec-live/storage/dropbox_spec.rb --tag init
93
+ Backup::Model.new(:archive_dropbox, 'test_label') do
94
+ archive :test_archive, &archive_job
95
+ store_with Dropbox
96
+ end
97
+
98
+ Backup::Model.new(:compressor_gzip_archive_local, 'test_label') do
99
+ archive :test_archive, &archive_job
100
+ compress_with Gzip
101
+ store_with Local
102
+ end
103
+
104
+ Backup::Model.new(:compressor_custom_archive_local, 'test_label') do
105
+ archive :test_archive, &archive_job
106
+ compress_with Custom do |c|
107
+ c.command = 'gzip -1'
108
+ c.extension = '.foo'
109
+ end
110
+ store_with Local
111
+ end
112
+
113
+ Backup::Model.new(:notifier_mail, 'test_label') do
114
+ notify_by Mail
115
+ end
116
+
117
+ Backup::Model.new(:notifier_mail_file, 'test_label') do
118
+ notify_by Mail do |mail|
119
+ mail.to = 'test@backup'
120
+ mail.delivery_method = :file
121
+ end
122
+ end
123
+
124
+ Backup::Model.new(:syncer_cloud_s3, 'test_label') do
125
+ sync_with Cloud::S3 do |s3|
126
+ s3.directories do
127
+ add File.join(Backup::SpecLive::SYNC_PATH, 'dir_a')
128
+ add File.join(Backup::SpecLive::SYNC_PATH, 'dir_b')
129
+ end
130
+ end
131
+ end
132
+
133
+ Backup::Model.new(:syncer_cloud_processes_s3, 'test_label') do
134
+ sync_with Cloud::S3 do |s3|
135
+ s3.concurrency_type = :processes
136
+ s3.concurrency_level = 2
137
+ s3.directories do
138
+ add File.join(Backup::SpecLive::SYNC_PATH, 'dir_a')
139
+ add File.join(Backup::SpecLive::SYNC_PATH, 'dir_b')
140
+ end
141
+ end
142
+ end
143
+
144
+ Backup::Model.new(:syncer_cloud_threads_s3, 'test_label') do
145
+ sync_with Cloud::S3 do |s3|
146
+ s3.concurrency_type = :threads
147
+ s3.concurrency_level = 2
148
+ s3.directories do
149
+ add File.join(Backup::SpecLive::SYNC_PATH, 'dir_a')
150
+ add File.join(Backup::SpecLive::SYNC_PATH, 'dir_b')
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,43 @@
1
+ ##
2
+ # config.yml template
3
+ # for usage, see:
4
+ # spec-live/spec_helper.rb
5
+ # spec-live/backups/config.rb
6
+ ##
7
+ ---
8
+ storage:
9
+ scp:
10
+ specs_enabled: false
11
+ username: <current user name>
12
+ password: <password>
13
+ ip: localhost
14
+ port: 22
15
+ path: /absolute/path/to/spec-live/tmp
16
+ dropbox:
17
+ specs_enabled: false
18
+ api_key: <your key>
19
+ api_secret: <your secret>
20
+ path:
21
+ timeout:
22
+ notifier:
23
+ mail:
24
+ specs_enabled: false
25
+ delivery_method: smtp
26
+ from: <from email>
27
+ to: <to email>
28
+ address: smtp.gmail.com
29
+ port: 587
30
+ user_name: <user name>
31
+ password: <password>
32
+ authentication: plain
33
+ enable_starttls_auto: true
34
+ sendmail:
35
+ sendmail_args:
36
+ syncer:
37
+ cloud:
38
+ s3:
39
+ specs_enabled: false
40
+ access_key_id:
41
+ secret_access_key:
42
+ bucket:
43
+ region:
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
+
5
+ describe 'Compressor::Custom' do
6
+
7
+ def archive_file_for(model)
8
+ File.join(
9
+ Backup::SpecLive::TMP_PATH,
10
+ "#{model.trigger}", model.time, "#{model.trigger}.tar"
11
+ )
12
+ end
13
+
14
+ def archive_contents_for(model)
15
+ archive_file = archive_file_for(model)
16
+ %x{ tar -tvf #{archive_file} }
17
+ end
18
+
19
+ it 'should compress an archive' do
20
+ model = h_set_trigger('compressor_custom_archive_local')
21
+ model.perform!
22
+ archive_file = archive_file_for(model)
23
+ File.exist?(archive_file).should be_true
24
+ archive_contents_for(model).should match(
25
+ /compressor_custom_archive_local\/archives\/test_archive\.tar\.foo/
26
+ )
27
+ File.stat(archive_file).size.should be > 0
28
+ end
29
+
30
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
+
5
+ describe 'Compressor::Gzip' do
6
+
7
+ def archive_file_for(model)
8
+ File.join(
9
+ Backup::SpecLive::TMP_PATH,
10
+ "#{model.trigger}", model.time, "#{model.trigger}.tar"
11
+ )
12
+ end
13
+
14
+ def archive_contents_for(model)
15
+ archive_file = archive_file_for(model)
16
+ %x{ tar -tvf #{archive_file} }
17
+ end
18
+
19
+ it 'should compress an archive' do
20
+ model = h_set_trigger('compressor_gzip_archive_local')
21
+ model.perform!
22
+ archive_file = archive_file_for(model)
23
+ File.exist?(archive_file).should be_true
24
+ archive_contents_for(model).should match(
25
+ /compressor_gzip_archive_local\/archives\/test_archive\.tar\.gz/
26
+ )
27
+ File.stat(archive_file).size.should be > 0
28
+ end
29
+
30
+ end
@@ -0,0 +1,85 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
+
5
+ describe 'Notifier::Mail',
6
+ :if => Backup::SpecLive::CONFIG['notifier']['mail']['specs_enabled'] do
7
+ describe 'Notifier::Mail :smtp' do
8
+ let(:trigger) { 'notifier_mail' }
9
+
10
+ it 'should send a success email' do
11
+ model = h_set_trigger(trigger)
12
+ expect do
13
+ model.perform!
14
+ end.not_to raise_error
15
+ end
16
+
17
+ it 'should send a warning email' do
18
+ model = h_set_trigger(trigger)
19
+ Backup::Logger.warn 'You have been warned!'
20
+ expect do
21
+ model.perform!
22
+ end.not_to raise_error
23
+ end
24
+
25
+ it 'should send a failure email for non-fatal errors' do
26
+ model = h_set_trigger(trigger)
27
+ model.stubs(:databases).raises('A successful failure?')
28
+ expect do
29
+ model.perform!
30
+ end.not_to raise_error
31
+ end
32
+
33
+ it 'should send a failure email fatal errors' do
34
+ model = h_set_trigger(trigger)
35
+ model.stubs(:databases).raises(NoMemoryError, 'with increasing frequency...')
36
+ expect do
37
+ model.perform!
38
+ end.to raise_error
39
+ end
40
+ end # describe 'Notifier::Mail :smtp'
41
+
42
+ describe 'Notifier::Mail :file' do
43
+ let(:trigger) { 'notifier_mail_file' }
44
+ let(:test_email) { File.join(Backup::SpecLive::TMP_PATH, 'test@backup') }
45
+
46
+ it 'should send a success email' do
47
+ model = h_set_trigger(trigger)
48
+ expect do
49
+ model.perform!
50
+ end.not_to raise_error
51
+ File.exist?(test_email).should be_true
52
+ File.read(test_email).should match(/without any errors/)
53
+ end
54
+
55
+ it 'should send a warning email' do
56
+ model = h_set_trigger(trigger)
57
+ Backup::Logger.warn 'You have been warned!'
58
+ expect do
59
+ model.perform!
60
+ end.not_to raise_error
61
+ File.exist?(test_email).should be_true
62
+ File.read(test_email).should match(/You have been warned/)
63
+ end
64
+
65
+ it 'should send a failure email for non-fatal errors' do
66
+ model = h_set_trigger(trigger)
67
+ model.stubs(:databases).raises('A successful failure?')
68
+ expect do
69
+ model.perform!
70
+ end.not_to raise_error
71
+ File.exist?(test_email).should be_true
72
+ File.read(test_email).should match(/successful failure/)
73
+ end
74
+
75
+ it 'should send a failure email fatal errors' do
76
+ model = h_set_trigger(trigger)
77
+ model.stubs(:databases).raises(NoMemoryError, 'with increasing frequency...')
78
+ expect do
79
+ model.perform!
80
+ end.to raise_error
81
+ File.exist?(test_email).should be_true
82
+ File.read(test_email).should match(/with increasing frequency/)
83
+ end
84
+ end # describe 'Notifier::Mail :file'
85
+ end