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.
- 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,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
|
-
|
|
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
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
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
|
|
|
@@ -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
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
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
|
|
data/lib/backup/version.rb
CHANGED
data/spec-live/README
ADDED
|
@@ -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
|