backupii 0.1.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +19 -0
- data/README.md +37 -0
- data/bin/backupii +5 -0
- data/bin/docker_test +24 -0
- data/lib/backup/archive.rb +171 -0
- data/lib/backup/binder.rb +23 -0
- data/lib/backup/cleaner.rb +114 -0
- data/lib/backup/cli.rb +376 -0
- data/lib/backup/cloud_io/base.rb +40 -0
- data/lib/backup/cloud_io/cloud_files.rb +301 -0
- data/lib/backup/cloud_io/s3.rb +256 -0
- data/lib/backup/compressor/base.rb +34 -0
- data/lib/backup/compressor/bzip2.rb +37 -0
- data/lib/backup/compressor/custom.rb +51 -0
- data/lib/backup/compressor/gzip.rb +76 -0
- data/lib/backup/config/dsl.rb +103 -0
- data/lib/backup/config/helpers.rb +139 -0
- data/lib/backup/config.rb +122 -0
- data/lib/backup/database/base.rb +89 -0
- data/lib/backup/database/mongodb.rb +189 -0
- data/lib/backup/database/mysql.rb +194 -0
- data/lib/backup/database/openldap.rb +97 -0
- data/lib/backup/database/postgresql.rb +134 -0
- data/lib/backup/database/redis.rb +179 -0
- data/lib/backup/database/riak.rb +82 -0
- data/lib/backup/database/sqlite.rb +57 -0
- data/lib/backup/encryptor/base.rb +29 -0
- data/lib/backup/encryptor/gpg.rb +745 -0
- data/lib/backup/encryptor/open_ssl.rb +76 -0
- data/lib/backup/errors.rb +55 -0
- data/lib/backup/logger/console.rb +50 -0
- data/lib/backup/logger/fog_adapter.rb +27 -0
- data/lib/backup/logger/logfile.rb +134 -0
- data/lib/backup/logger/syslog.rb +116 -0
- data/lib/backup/logger.rb +199 -0
- data/lib/backup/model.rb +478 -0
- data/lib/backup/notifier/base.rb +128 -0
- data/lib/backup/notifier/campfire.rb +63 -0
- data/lib/backup/notifier/command.rb +101 -0
- data/lib/backup/notifier/datadog.rb +107 -0
- data/lib/backup/notifier/flowdock.rb +101 -0
- data/lib/backup/notifier/hipchat.rb +118 -0
- data/lib/backup/notifier/http_post.rb +116 -0
- data/lib/backup/notifier/mail.rb +235 -0
- data/lib/backup/notifier/nagios.rb +67 -0
- data/lib/backup/notifier/pagerduty.rb +82 -0
- data/lib/backup/notifier/prowl.rb +70 -0
- data/lib/backup/notifier/pushover.rb +73 -0
- data/lib/backup/notifier/ses.rb +126 -0
- data/lib/backup/notifier/slack.rb +149 -0
- data/lib/backup/notifier/twitter.rb +57 -0
- data/lib/backup/notifier/zabbix.rb +62 -0
- data/lib/backup/package.rb +53 -0
- data/lib/backup/packager.rb +108 -0
- data/lib/backup/pipeline.rb +122 -0
- data/lib/backup/splitter.rb +75 -0
- data/lib/backup/storage/base.rb +72 -0
- data/lib/backup/storage/cloud_files.rb +158 -0
- data/lib/backup/storage/cycler.rb +73 -0
- data/lib/backup/storage/dropbox.rb +208 -0
- data/lib/backup/storage/ftp.rb +118 -0
- data/lib/backup/storage/local.rb +63 -0
- data/lib/backup/storage/qiniu.rb +68 -0
- data/lib/backup/storage/rsync.rb +251 -0
- data/lib/backup/storage/s3.rb +157 -0
- data/lib/backup/storage/scp.rb +67 -0
- data/lib/backup/storage/sftp.rb +82 -0
- data/lib/backup/syncer/base.rb +70 -0
- data/lib/backup/syncer/cloud/base.rb +180 -0
- data/lib/backup/syncer/cloud/cloud_files.rb +83 -0
- data/lib/backup/syncer/cloud/local_file.rb +99 -0
- data/lib/backup/syncer/cloud/s3.rb +118 -0
- data/lib/backup/syncer/rsync/base.rb +55 -0
- data/lib/backup/syncer/rsync/local.rb +29 -0
- data/lib/backup/syncer/rsync/pull.rb +49 -0
- data/lib/backup/syncer/rsync/push.rb +206 -0
- data/lib/backup/template.rb +45 -0
- data/lib/backup/utilities.rb +235 -0
- data/lib/backup/version.rb +5 -0
- data/lib/backup.rb +141 -0
- data/templates/cli/archive +28 -0
- data/templates/cli/compressor/bzip2 +4 -0
- data/templates/cli/compressor/custom +7 -0
- data/templates/cli/compressor/gzip +4 -0
- data/templates/cli/config +123 -0
- data/templates/cli/databases/mongodb +15 -0
- data/templates/cli/databases/mysql +18 -0
- data/templates/cli/databases/openldap +24 -0
- data/templates/cli/databases/postgresql +16 -0
- data/templates/cli/databases/redis +16 -0
- data/templates/cli/databases/riak +17 -0
- data/templates/cli/databases/sqlite +11 -0
- data/templates/cli/encryptor/gpg +27 -0
- data/templates/cli/encryptor/openssl +9 -0
- data/templates/cli/model +26 -0
- data/templates/cli/notifier/zabbix +15 -0
- data/templates/cli/notifiers/campfire +12 -0
- data/templates/cli/notifiers/command +32 -0
- data/templates/cli/notifiers/datadog +57 -0
- data/templates/cli/notifiers/flowdock +16 -0
- data/templates/cli/notifiers/hipchat +16 -0
- data/templates/cli/notifiers/http_post +32 -0
- data/templates/cli/notifiers/mail +24 -0
- data/templates/cli/notifiers/nagios +13 -0
- data/templates/cli/notifiers/pagerduty +12 -0
- data/templates/cli/notifiers/prowl +11 -0
- data/templates/cli/notifiers/pushover +11 -0
- data/templates/cli/notifiers/ses +15 -0
- data/templates/cli/notifiers/slack +22 -0
- data/templates/cli/notifiers/twitter +13 -0
- data/templates/cli/splitter +7 -0
- data/templates/cli/storages/cloud_files +11 -0
- data/templates/cli/storages/dropbox +20 -0
- data/templates/cli/storages/ftp +13 -0
- data/templates/cli/storages/local +8 -0
- data/templates/cli/storages/qiniu +12 -0
- data/templates/cli/storages/rsync +17 -0
- data/templates/cli/storages/s3 +16 -0
- data/templates/cli/storages/scp +15 -0
- data/templates/cli/storages/sftp +15 -0
- data/templates/cli/syncers/cloud_files +22 -0
- data/templates/cli/syncers/rsync_local +20 -0
- data/templates/cli/syncers/rsync_pull +28 -0
- data/templates/cli/syncers/rsync_push +28 -0
- data/templates/cli/syncers/s3 +27 -0
- data/templates/general/links +3 -0
- data/templates/general/version.erb +2 -0
- data/templates/notifier/mail/failure.erb +16 -0
- data/templates/notifier/mail/success.erb +16 -0
- data/templates/notifier/mail/warning.erb +16 -0
- data/templates/storage/dropbox/authorization_url.erb +6 -0
- data/templates/storage/dropbox/authorized.erb +4 -0
- data/templates/storage/dropbox/cache_file_written.erb +10 -0
- metadata +507 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: db08b57a1783a56efe5583ab413bf42721a5d2c7c5a4567fe523ddc0068e7874
|
4
|
+
data.tar.gz: 4858c38e6c35d3c80429bb8a9311f3f152f632551a80eeebbbc27a8aab6c3087
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9e2361e3b6afd6cc9e34b766fdd4eb4744b47492b97ce9763efb02ed2f60a89abc2c6c2dda95adf9b26ada65dae2286e6c2f9322feffe95d0bfd7c4ccbc3cb7d
|
7
|
+
data.tar.gz: ee8027246ecb416e99ca09066789b5437a1ff147f29020fe78206e267ffa7389330f374ffc13aca1147b2c900a862c09d451246064c56d6e3dccf2c4844ca71b
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2009-2017 Michael van Rooijen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Backup II
|
2
|
+
=========
|
3
|
+
|
4
|
+
[![Code Climate](https://codeclimate.com/github/backupii/backupii.svg)](https://codeclimate.com/github/backupii/backupii)
|
5
|
+
[![Build Status](https://travis-ci.org/backupii/backupii.svg?branch=master)](https://travis-ci.org/backupii/backupii)
|
6
|
+
|
7
|
+
> This project is a fork of the excellent but un-maintained backup gem.
|
8
|
+
|
9
|
+
BackupII is a system utility for Linux and Mac OS X, distributed as a
|
10
|
+
RubyGem, that allows you to easily perform backup operations. It
|
11
|
+
provides an elegant DSL in Ruby for _modeling_ your backups. BackupII
|
12
|
+
has built-in support for various databases, storage
|
13
|
+
protocols/services, syncers, compressors, encryptors and notifiers
|
14
|
+
which you can mix and match. It was built with modularity,
|
15
|
+
extensibility and simplicity in mind.
|
16
|
+
|
17
|
+
[Installation][] · [Release Notes][] · [Documentation][] · [Issues][] · [Contributing and getting started][]
|
18
|
+
|
19
|
+
## Project Status: Forking just started ##
|
20
|
+
|
21
|
+
I'm giving a try on taking over the maintenance of this project as I'm
|
22
|
+
using it on many infrastructure and overall like it very much.
|
23
|
+
|
24
|
+
If you use this project and would like to develop it further, please
|
25
|
+
introduce yourself on the [maintainers wanted][Maintainers wanted]
|
26
|
+
ticket.
|
27
|
+
|
28
|
+
**Copyright (c) 2009-2017 [Michael van Rooijen][]**
|
29
|
+
Released under the **MIT** [LICENSE](LICENSE).
|
30
|
+
|
31
|
+
[Installation]: http://backupii.github.io/backupii/v0/installation
|
32
|
+
[Release Notes]: http://backupii.github.io/backupii/v0/release-notes
|
33
|
+
[Documentation]: http://backupii.github.io/backupii/v0
|
34
|
+
[Issues]: https://github.com/backupii/backupii/issues
|
35
|
+
[Contributing and getting started]: CONTRIBUTING.md
|
36
|
+
[Maintainers wanted]: https://github.com/backupii/backupii/issues/1
|
37
|
+
[Michael van Rooijen]: http://github.com/mrrooijen
|
data/bin/backupii
ADDED
data/bin/docker_test
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -eu
|
3
|
+
|
4
|
+
export BUNDLE_PATH=/tmp/docker/bundle
|
5
|
+
export BUNDLE_JOBS=4
|
6
|
+
|
7
|
+
case "${1-}" in
|
8
|
+
prepare)
|
9
|
+
bundle check || bundle install
|
10
|
+
;;
|
11
|
+
rspec)
|
12
|
+
bundle exec rspec spec
|
13
|
+
;;
|
14
|
+
integration)
|
15
|
+
bundle exec rspec integration/acceptance/
|
16
|
+
;;
|
17
|
+
console)
|
18
|
+
bash
|
19
|
+
;;
|
20
|
+
*)
|
21
|
+
echo "Task not found"
|
22
|
+
exit 1
|
23
|
+
;;
|
24
|
+
esac
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
class Archive
|
5
|
+
class Error < Backup::Error; end
|
6
|
+
|
7
|
+
include Utilities::Helpers
|
8
|
+
attr_reader :name, :options
|
9
|
+
|
10
|
+
##
|
11
|
+
# Adds a new Archive to a Backup Model.
|
12
|
+
#
|
13
|
+
# Backup::Model.new(:my_backup, 'My Backup') do
|
14
|
+
# archive :my_archive do |archive|
|
15
|
+
# archive.add 'path/to/archive'
|
16
|
+
# archive.add '/another/path/to/archive'
|
17
|
+
# archive.exclude 'path/to/exclude'
|
18
|
+
# archive.exclude '/another/path/to/exclude'
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# All paths added using `add` or `exclude` will be expanded to their
|
23
|
+
# full paths from the root of the filesystem. Files will be added to
|
24
|
+
# the tar archive using these full paths, and their leading `/` will
|
25
|
+
# be preserved (using tar's `-P` option).
|
26
|
+
#
|
27
|
+
# /path/to/pwd/path/to/archive/...
|
28
|
+
# /another/path/to/archive/...
|
29
|
+
#
|
30
|
+
# When a `root` path is given, paths to add/exclude are taken as
|
31
|
+
# relative to the `root` path, unless given as absolute paths.
|
32
|
+
#
|
33
|
+
# Backup::Model.new(:my_backup, 'My Backup') do
|
34
|
+
# archive :my_archive do |archive|
|
35
|
+
# archive.root '~/my_data'
|
36
|
+
# archive.add 'path/to/archive'
|
37
|
+
# archive.add '/another/path/to/archive'
|
38
|
+
# archive.exclude 'path/to/exclude'
|
39
|
+
# archive.exclude '/another/path/to/exclude'
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# This directs `tar` to change directories to the `root` path to create
|
44
|
+
# the archive. Unless paths were given as absolute, the paths within the
|
45
|
+
# archive will be relative to the `root` path.
|
46
|
+
#
|
47
|
+
# path/to/archive/...
|
48
|
+
# /another/path/to/archive/...
|
49
|
+
#
|
50
|
+
# For absolute paths added to this archive, the leading `/` will be
|
51
|
+
# preserved. Take note that when archives are extracted, leading `/` are
|
52
|
+
# stripped by default, so care must be taken when extracting archives with
|
53
|
+
# mixed relative/absolute paths.
|
54
|
+
def initialize(model, name, &block)
|
55
|
+
@model = model
|
56
|
+
@name = name.to_s
|
57
|
+
@options = {
|
58
|
+
sudo: false,
|
59
|
+
root: false,
|
60
|
+
paths: [],
|
61
|
+
excludes: [],
|
62
|
+
tar_options: ""
|
63
|
+
}
|
64
|
+
DSL.new(@options).instance_eval(&block)
|
65
|
+
end
|
66
|
+
|
67
|
+
def perform!
|
68
|
+
Logger.info "Creating Archive '#{name}'..."
|
69
|
+
|
70
|
+
path = File.join(Config.tmp_path, @model.trigger, "archives")
|
71
|
+
FileUtils.mkdir_p(path)
|
72
|
+
|
73
|
+
pipeline = Pipeline.new
|
74
|
+
with_files_from(paths_to_package) do |files_from|
|
75
|
+
pipeline.add(
|
76
|
+
"#{tar_command} #{tar_options} -cPf -#{tar_root} " \
|
77
|
+
"#{paths_to_exclude} #{files_from}",
|
78
|
+
tar_success_codes
|
79
|
+
)
|
80
|
+
|
81
|
+
extension = "tar".dup
|
82
|
+
if @model.compressor
|
83
|
+
@model.compressor.compress_with do |command, ext|
|
84
|
+
pipeline << command
|
85
|
+
extension << ext
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
pipeline << "#{utility(:cat)} > " \
|
90
|
+
"'#{File.join(path, "#{name}.#{extension}")}'"
|
91
|
+
pipeline.run
|
92
|
+
end
|
93
|
+
|
94
|
+
if pipeline.success?
|
95
|
+
Logger.info "Archive '#{name}' Complete!"
|
96
|
+
else
|
97
|
+
raise Error, "Failed to Create Archive '#{name}'\n" +
|
98
|
+
pipeline.error_messages
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def tar_command
|
105
|
+
tar = utility(:tar)
|
106
|
+
options[:sudo] ? "#{utility(:sudo)} -n #{tar}" : tar
|
107
|
+
end
|
108
|
+
|
109
|
+
def tar_root
|
110
|
+
options[:root] ? " -C '#{File.expand_path(options[:root])}'" : ""
|
111
|
+
end
|
112
|
+
|
113
|
+
def paths_to_package
|
114
|
+
options[:paths].map { |path| prepare_path(path) }
|
115
|
+
end
|
116
|
+
|
117
|
+
def with_files_from(paths)
|
118
|
+
tmpfile = Tempfile.new("backup-archive-paths")
|
119
|
+
paths.each { |path| tmpfile.puts path }
|
120
|
+
tmpfile.close
|
121
|
+
yield "-T '#{tmpfile.path}'"
|
122
|
+
ensure
|
123
|
+
tmpfile.delete
|
124
|
+
end
|
125
|
+
|
126
|
+
def paths_to_exclude
|
127
|
+
options[:excludes].map do |path|
|
128
|
+
"--exclude='#{prepare_path(path)}'"
|
129
|
+
end.join(" ")
|
130
|
+
end
|
131
|
+
|
132
|
+
def prepare_path(path)
|
133
|
+
options[:root] ? path : File.expand_path(path)
|
134
|
+
end
|
135
|
+
|
136
|
+
def tar_options
|
137
|
+
args = options[:tar_options]
|
138
|
+
gnu_tar? ? "--ignore-failed-read #{args}".strip : args
|
139
|
+
end
|
140
|
+
|
141
|
+
def tar_success_codes
|
142
|
+
gnu_tar? ? [0, 1] : [0]
|
143
|
+
end
|
144
|
+
|
145
|
+
class DSL
|
146
|
+
def initialize(options)
|
147
|
+
@options = options
|
148
|
+
end
|
149
|
+
|
150
|
+
def use_sudo(val = true)
|
151
|
+
@options[:sudo] = val
|
152
|
+
end
|
153
|
+
|
154
|
+
def root(path)
|
155
|
+
@options[:root] = path
|
156
|
+
end
|
157
|
+
|
158
|
+
def add(path)
|
159
|
+
@options[:paths] << path
|
160
|
+
end
|
161
|
+
|
162
|
+
def exclude(path)
|
163
|
+
@options[:excludes] << path
|
164
|
+
end
|
165
|
+
|
166
|
+
def tar_options(opts)
|
167
|
+
@options[:tar_options] = opts
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
class Binder
|
5
|
+
##
|
6
|
+
# Creates a new Backup::Notifier::Binder instance. Loops through the
|
7
|
+
# provided Hash to set instance variables
|
8
|
+
def initialize(key_and_values)
|
9
|
+
key_and_values.each do |key, value|
|
10
|
+
instance_variable_set("@#{key}", value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# Returns the binding (needs a wrapper method because #binding is a private
|
16
|
+
# method)
|
17
|
+
# rubocop:disable Naming/AccessorMethodName
|
18
|
+
def get_binding
|
19
|
+
binding
|
20
|
+
end
|
21
|
+
# rubocop:enable Naming/AccessorMethodName
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
module Cleaner
|
5
|
+
class Error < Backup::Error; end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
##
|
9
|
+
# Logs warnings if any temporary files still exist
|
10
|
+
# from the last time this model/trigger was run,
|
11
|
+
# then removes the files.
|
12
|
+
def prepare(model)
|
13
|
+
messages = []
|
14
|
+
|
15
|
+
packaging_folder = File.join(Config.tmp_path, model.trigger)
|
16
|
+
if File.exist?(packaging_folder)
|
17
|
+
messages << <<-EOS
|
18
|
+
The temporary packaging folder still exists!
|
19
|
+
'#{packaging_folder}'
|
20
|
+
It will now be removed.
|
21
|
+
EOS
|
22
|
+
FileUtils.rm_rf(packaging_folder)
|
23
|
+
end
|
24
|
+
|
25
|
+
package_files = package_files_for(model.trigger)
|
26
|
+
unless package_files.empty?
|
27
|
+
# the chances of the packaging folder AND
|
28
|
+
# the package files existing are practically nil
|
29
|
+
messages << ("-" * 74) unless messages.empty?
|
30
|
+
|
31
|
+
messages << <<-EOS
|
32
|
+
The temporary backup folder '#{Config.tmp_path}'
|
33
|
+
appears to contain the package files from the previous backup!
|
34
|
+
#{package_files.join("\n")}
|
35
|
+
These files will now be removed.
|
36
|
+
EOS
|
37
|
+
package_files.each { |file| FileUtils.rm_f(file) }
|
38
|
+
end
|
39
|
+
|
40
|
+
unless messages.empty?
|
41
|
+
Logger.warn Error.new(<<-EOS)
|
42
|
+
Cleanup Warning
|
43
|
+
#{messages.join("\n")}
|
44
|
+
Please check the log for messages and/or your notifications
|
45
|
+
concerning this backup: '#{model.label} (#{model.trigger})'
|
46
|
+
The temporary files which had to be removed should not have existed.
|
47
|
+
EOS
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Remove the temporary folder used during packaging
|
53
|
+
def remove_packaging(model)
|
54
|
+
Logger.info "Cleaning up the temporary files..."
|
55
|
+
FileUtils.rm_rf(File.join(Config.tmp_path, model.trigger))
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Remove the final package files from tmp_path
|
60
|
+
# Note: 'force' is used, since a Local Storage may *move* these files.
|
61
|
+
def remove_package(package)
|
62
|
+
Logger.info "Cleaning up the package files..."
|
63
|
+
package.filenames.each do |file|
|
64
|
+
FileUtils.rm_f(File.join(Config.tmp_path, file))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# Logs warnings if any temporary files still exist
|
70
|
+
# when errors occur during the backup
|
71
|
+
def warnings(model)
|
72
|
+
messages = []
|
73
|
+
|
74
|
+
packaging_folder = File.join(Config.tmp_path, model.trigger)
|
75
|
+
if File.exist?(packaging_folder)
|
76
|
+
messages << <<-EOS
|
77
|
+
The temporary packaging folder still exists!
|
78
|
+
'#{packaging_folder}'
|
79
|
+
This folder may contain completed Archives and/or Database backups.
|
80
|
+
EOS
|
81
|
+
end
|
82
|
+
|
83
|
+
package_files = package_files_for(model.trigger)
|
84
|
+
unless package_files.empty?
|
85
|
+
# the chances of the packaging folder AND
|
86
|
+
# the package files existing are practically nil
|
87
|
+
messages << ("-" * 74) unless messages.empty?
|
88
|
+
|
89
|
+
messages << <<-EOS
|
90
|
+
The temporary backup folder '#{Config.tmp_path}'
|
91
|
+
appears to contain the backup files which were to be stored:
|
92
|
+
#{package_files.join("\n")}
|
93
|
+
EOS
|
94
|
+
end
|
95
|
+
|
96
|
+
unless messages.empty?
|
97
|
+
Logger.warn Error.new(<<-EOS)
|
98
|
+
Cleanup Warning
|
99
|
+
#{messages.join("\n")}
|
100
|
+
Make sure you check these files before the next scheduled backup for
|
101
|
+
'#{model.label} (#{model.trigger})'
|
102
|
+
These files will be removed at that time!
|
103
|
+
EOS
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def package_files_for(trigger)
|
110
|
+
Dir[File.join(Config.tmp_path, "#{trigger}.tar{,[.-]*}")]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|