backup 4.4.1 → 5.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +19 -0
  3. data/README.md +1 -1
  4. data/lib/backup.rb +74 -78
  5. data/lib/backup/archive.rb +31 -32
  6. data/lib/backup/binder.rb +2 -6
  7. data/lib/backup/cleaner.rb +14 -18
  8. data/lib/backup/cli.rb +104 -108
  9. data/lib/backup/cloud_io/base.rb +4 -7
  10. data/lib/backup/cloud_io/cloud_files.rb +60 -62
  11. data/lib/backup/cloud_io/s3.rb +69 -76
  12. data/lib/backup/compressor/base.rb +4 -7
  13. data/lib/backup/compressor/bzip2.rb +3 -7
  14. data/lib/backup/compressor/custom.rb +2 -6
  15. data/lib/backup/compressor/gzip.rb +16 -17
  16. data/lib/backup/config.rb +17 -18
  17. data/lib/backup/config/dsl.rb +16 -17
  18. data/lib/backup/config/helpers.rb +10 -16
  19. data/lib/backup/database/base.rb +22 -21
  20. data/lib/backup/database/mongodb.rb +36 -37
  21. data/lib/backup/database/mysql.rb +40 -41
  22. data/lib/backup/database/openldap.rb +8 -10
  23. data/lib/backup/database/postgresql.rb +29 -30
  24. data/lib/backup/database/redis.rb +27 -30
  25. data/lib/backup/database/riak.rb +15 -18
  26. data/lib/backup/database/sqlite.rb +4 -6
  27. data/lib/backup/encryptor/base.rb +2 -4
  28. data/lib/backup/encryptor/gpg.rb +49 -59
  29. data/lib/backup/encryptor/open_ssl.rb +11 -14
  30. data/lib/backup/errors.rb +7 -12
  31. data/lib/backup/logger.rb +16 -18
  32. data/lib/backup/logger/console.rb +5 -8
  33. data/lib/backup/logger/fog_adapter.rb +2 -6
  34. data/lib/backup/logger/logfile.rb +10 -12
  35. data/lib/backup/logger/syslog.rb +2 -4
  36. data/lib/backup/model.rb +75 -40
  37. data/lib/backup/notifier/base.rb +24 -26
  38. data/lib/backup/notifier/campfire.rb +9 -11
  39. data/lib/backup/notifier/command.rb +0 -3
  40. data/lib/backup/notifier/datadog.rb +9 -12
  41. data/lib/backup/notifier/flowdock.rb +13 -17
  42. data/lib/backup/notifier/hipchat.rb +11 -13
  43. data/lib/backup/notifier/http_post.rb +11 -14
  44. data/lib/backup/notifier/mail.rb +44 -47
  45. data/lib/backup/notifier/nagios.rb +5 -9
  46. data/lib/backup/notifier/pagerduty.rb +10 -12
  47. data/lib/backup/notifier/prowl.rb +15 -15
  48. data/lib/backup/notifier/pushover.rb +7 -10
  49. data/lib/backup/notifier/ses.rb +34 -16
  50. data/lib/backup/notifier/slack.rb +39 -40
  51. data/lib/backup/notifier/twitter.rb +2 -5
  52. data/lib/backup/notifier/zabbix.rb +11 -14
  53. data/lib/backup/package.rb +5 -9
  54. data/lib/backup/packager.rb +16 -17
  55. data/lib/backup/pipeline.rb +17 -21
  56. data/lib/backup/splitter.rb +8 -11
  57. data/lib/backup/storage/base.rb +5 -8
  58. data/lib/backup/storage/cloud_files.rb +21 -23
  59. data/lib/backup/storage/cycler.rb +10 -15
  60. data/lib/backup/storage/dropbox.rb +15 -21
  61. data/lib/backup/storage/ftp.rb +8 -10
  62. data/lib/backup/storage/local.rb +5 -8
  63. data/lib/backup/storage/qiniu.rb +8 -8
  64. data/lib/backup/storage/rsync.rb +24 -26
  65. data/lib/backup/storage/s3.rb +27 -28
  66. data/lib/backup/storage/scp.rb +10 -12
  67. data/lib/backup/storage/sftp.rb +10 -12
  68. data/lib/backup/syncer/base.rb +5 -8
  69. data/lib/backup/syncer/cloud/base.rb +27 -30
  70. data/lib/backup/syncer/cloud/cloud_files.rb +16 -18
  71. data/lib/backup/syncer/cloud/local_file.rb +5 -8
  72. data/lib/backup/syncer/cloud/s3.rb +23 -24
  73. data/lib/backup/syncer/rsync/base.rb +6 -10
  74. data/lib/backup/syncer/rsync/local.rb +1 -5
  75. data/lib/backup/syncer/rsync/pull.rb +6 -10
  76. data/lib/backup/syncer/rsync/push.rb +18 -22
  77. data/lib/backup/template.rb +9 -14
  78. data/lib/backup/utilities.rb +82 -69
  79. data/lib/backup/version.rb +1 -3
  80. metadata +100 -660
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 27f2f7a25217955273c6b721509dacde87c0ba06715004ee3cf732262a4e3fed
4
- data.tar.gz: ee514abc68b3d0ecb52f6965b14dac5d6ac8d17386a5ae8ef46029cf6aa332a3
2
+ SHA1:
3
+ metadata.gz: 3e90aa060ddb761e49388d59c63e4a347ff31b10
4
+ data.tar.gz: 6daf2c1c7fc2522c806f8cee757d8dbbf024c099
5
5
  SHA512:
6
- metadata.gz: 0015adf0f7e1b5e226866a11cdd658c129853508df5301c9df641fd377e55e9c73271577aca41d4d57178ba67238f9cd39d2fbce82fe6f89052f1977292138c3
7
- data.tar.gz: d338cf0df9fc344c283aa14cc31e17ebe912e51f49e210ab873941986548c56af72a3acccb0dc259131c12727c5d6957eb535bbad52a11667a399799a5bd2d24
6
+ metadata.gz: fec34c486f7f34829928cca1342ca9986dfd072dae3c3dffa05cfc247547dff113c72d53c9d354d9157d68bf20945b11f07787e02584cda4d28cb554e397cd0d
7
+ data.tar.gz: 37a71a5c1603c4a280874f07ebc5156daef997ebb0e931a031224d0a79c4af6d502ddc4b4512fb64f38b2624458135300adcf2579c77b9d9e6e284ebcf7203cc
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 CHANGED
@@ -16,7 +16,7 @@ Please use the Backup features [issue tracker][Features] to suggest new features
16
16
  Only use the Backup gem [issue tracker][Issues] for bugs and other issues.
17
17
  We're also available on [Gitter] for questions and problems.
18
18
 
19
- **Copyright (c) 2009-2016 [Michael van Rooijen][] ( [@mrrooijen] )**
19
+ **Copyright (c) 2009-2017 [Michael van Rooijen][] ( [@mrrooijen] )**
20
20
  Released under the **MIT** [LICENSE](LICENSE).
21
21
 
22
22
  [Installation]: http://backup.github.io/backup/v4/installation
@@ -1,20 +1,18 @@
1
- # encoding: utf-8
2
-
3
1
  # Load Ruby Core Libraries
4
- require 'time'
5
- require 'fileutils'
6
- require 'tempfile'
7
- require 'syslog'
8
- require 'yaml'
9
- require 'etc'
10
- require 'forwardable'
11
- require 'thread'
2
+ require "time"
3
+ require "fileutils"
4
+ require "tempfile"
5
+ require "syslog"
6
+ require "yaml"
7
+ require "etc"
8
+ require "forwardable"
9
+ require "thread"
12
10
 
13
- require 'open4'
14
- require 'thor'
15
- require 'shellwords'
11
+ require "open4"
12
+ require "thor"
13
+ require "shellwords"
16
14
 
17
- require 'excon'
15
+ require "excon"
18
16
  # Include response.inspect in error messages.
19
17
  Excon.defaults[:debug_response] = true
20
18
  # Excon should not retry failed requests. We handle that.
@@ -23,107 +21,106 @@ Excon.defaults[:middlewares].delete(Excon::Middleware::Idempotent)
23
21
  ##
24
22
  # The Backup Ruby Gem
25
23
  module Backup
26
-
27
24
  ##
28
25
  # Backup's internal paths
29
- LIBRARY_PATH = File.join(File.dirname(__FILE__), 'backup')
30
- STORAGE_PATH = File.join(LIBRARY_PATH, 'storage')
31
- SYNCER_PATH = File.join(LIBRARY_PATH, 'syncer')
32
- DATABASE_PATH = File.join(LIBRARY_PATH, 'database')
33
- COMPRESSOR_PATH = File.join(LIBRARY_PATH, 'compressor')
34
- ENCRYPTOR_PATH = File.join(LIBRARY_PATH, 'encryptor')
35
- NOTIFIER_PATH = File.join(LIBRARY_PATH, 'notifier')
36
- TEMPLATE_PATH = File.expand_path('../../templates', __FILE__)
26
+ LIBRARY_PATH = File.join(File.dirname(__FILE__), "backup")
27
+ STORAGE_PATH = File.join(LIBRARY_PATH, "storage")
28
+ SYNCER_PATH = File.join(LIBRARY_PATH, "syncer")
29
+ DATABASE_PATH = File.join(LIBRARY_PATH, "database")
30
+ COMPRESSOR_PATH = File.join(LIBRARY_PATH, "compressor")
31
+ ENCRYPTOR_PATH = File.join(LIBRARY_PATH, "encryptor")
32
+ NOTIFIER_PATH = File.join(LIBRARY_PATH, "notifier")
33
+ TEMPLATE_PATH = File.expand_path("../../templates", __FILE__)
37
34
 
38
35
  ##
39
36
  # Autoload Backup storage files
40
37
  module Storage
41
- autoload :Base, File.join(STORAGE_PATH, 'base')
42
- autoload :Cycler, File.join(STORAGE_PATH, 'cycler')
43
- autoload :S3, File.join(STORAGE_PATH, 's3')
44
- autoload :CloudFiles, File.join(STORAGE_PATH, 'cloud_files')
45
- autoload :Ninefold, File.join(STORAGE_PATH, 'ninefold')
46
- autoload :Dropbox, File.join(STORAGE_PATH, 'dropbox')
47
- autoload :FTP, File.join(STORAGE_PATH, 'ftp')
48
- autoload :SFTP, File.join(STORAGE_PATH, 'sftp')
49
- autoload :SCP, File.join(STORAGE_PATH, 'scp')
50
- autoload :RSync, File.join(STORAGE_PATH, 'rsync')
51
- autoload :Local, File.join(STORAGE_PATH, 'local')
52
- autoload :Qiniu, File.join(STORAGE_PATH, 'qiniu')
38
+ autoload :Base, File.join(STORAGE_PATH, "base")
39
+ autoload :Cycler, File.join(STORAGE_PATH, "cycler")
40
+ autoload :S3, File.join(STORAGE_PATH, "s3")
41
+ autoload :CloudFiles, File.join(STORAGE_PATH, "cloud_files")
42
+ autoload :Ninefold, File.join(STORAGE_PATH, "ninefold")
43
+ autoload :Dropbox, File.join(STORAGE_PATH, "dropbox")
44
+ autoload :FTP, File.join(STORAGE_PATH, "ftp")
45
+ autoload :SFTP, File.join(STORAGE_PATH, "sftp")
46
+ autoload :SCP, File.join(STORAGE_PATH, "scp")
47
+ autoload :RSync, File.join(STORAGE_PATH, "rsync")
48
+ autoload :Local, File.join(STORAGE_PATH, "local")
49
+ autoload :Qiniu, File.join(STORAGE_PATH, "qiniu")
53
50
  end
54
51
 
55
52
  ##
56
53
  # Autoload Backup syncer files
57
54
  module Syncer
58
- autoload :Base, File.join(SYNCER_PATH, 'base')
55
+ autoload :Base, File.join(SYNCER_PATH, "base")
59
56
  module Cloud
60
- autoload :Base, File.join(SYNCER_PATH, 'cloud', 'base')
61
- autoload :LocalFile, File.join(SYNCER_PATH, 'cloud', 'local_file')
62
- autoload :CloudFiles, File.join(SYNCER_PATH, 'cloud', 'cloud_files')
63
- autoload :S3, File.join(SYNCER_PATH, 'cloud', 's3')
57
+ autoload :Base, File.join(SYNCER_PATH, "cloud", "base")
58
+ autoload :LocalFile, File.join(SYNCER_PATH, "cloud", "local_file")
59
+ autoload :CloudFiles, File.join(SYNCER_PATH, "cloud", "cloud_files")
60
+ autoload :S3, File.join(SYNCER_PATH, "cloud", "s3")
64
61
  end
65
62
  module RSync
66
- autoload :Base, File.join(SYNCER_PATH, 'rsync', 'base')
67
- autoload :Local, File.join(SYNCER_PATH, 'rsync', 'local')
68
- autoload :Push, File.join(SYNCER_PATH, 'rsync', 'push')
69
- autoload :Pull, File.join(SYNCER_PATH, 'rsync', 'pull')
63
+ autoload :Base, File.join(SYNCER_PATH, "rsync", "base")
64
+ autoload :Local, File.join(SYNCER_PATH, "rsync", "local")
65
+ autoload :Push, File.join(SYNCER_PATH, "rsync", "push")
66
+ autoload :Pull, File.join(SYNCER_PATH, "rsync", "pull")
70
67
  end
71
68
  end
72
69
 
73
70
  ##
74
71
  # Autoload Backup database files
75
72
  module Database
76
- autoload :Base, File.join(DATABASE_PATH, 'base')
77
- autoload :MySQL, File.join(DATABASE_PATH, 'mysql')
78
- autoload :PostgreSQL, File.join(DATABASE_PATH, 'postgresql')
79
- autoload :MongoDB, File.join(DATABASE_PATH, 'mongodb')
80
- autoload :Redis, File.join(DATABASE_PATH, 'redis')
81
- autoload :Riak, File.join(DATABASE_PATH, 'riak')
82
- autoload :OpenLDAP, File.join(DATABASE_PATH, 'openldap')
83
- autoload :SQLite, File.join(DATABASE_PATH, 'sqlite')
73
+ autoload :Base, File.join(DATABASE_PATH, "base")
74
+ autoload :MySQL, File.join(DATABASE_PATH, "mysql")
75
+ autoload :PostgreSQL, File.join(DATABASE_PATH, "postgresql")
76
+ autoload :MongoDB, File.join(DATABASE_PATH, "mongodb")
77
+ autoload :Redis, File.join(DATABASE_PATH, "redis")
78
+ autoload :Riak, File.join(DATABASE_PATH, "riak")
79
+ autoload :OpenLDAP, File.join(DATABASE_PATH, "openldap")
80
+ autoload :SQLite, File.join(DATABASE_PATH, "sqlite")
84
81
  end
85
82
 
86
83
  ##
87
84
  # Autoload compressor files
88
85
  module Compressor
89
- autoload :Base, File.join(COMPRESSOR_PATH, 'base')
90
- autoload :Gzip, File.join(COMPRESSOR_PATH, 'gzip')
91
- autoload :Bzip2, File.join(COMPRESSOR_PATH, 'bzip2')
92
- autoload :Custom, File.join(COMPRESSOR_PATH, 'custom')
86
+ autoload :Base, File.join(COMPRESSOR_PATH, "base")
87
+ autoload :Gzip, File.join(COMPRESSOR_PATH, "gzip")
88
+ autoload :Bzip2, File.join(COMPRESSOR_PATH, "bzip2")
89
+ autoload :Custom, File.join(COMPRESSOR_PATH, "custom")
93
90
  end
94
91
 
95
92
  ##
96
93
  # Autoload encryptor files
97
94
  module Encryptor
98
- autoload :Base, File.join(ENCRYPTOR_PATH, 'base')
99
- autoload :OpenSSL, File.join(ENCRYPTOR_PATH, 'open_ssl')
100
- autoload :GPG, File.join(ENCRYPTOR_PATH, 'gpg')
95
+ autoload :Base, File.join(ENCRYPTOR_PATH, "base")
96
+ autoload :OpenSSL, File.join(ENCRYPTOR_PATH, "open_ssl")
97
+ autoload :GPG, File.join(ENCRYPTOR_PATH, "gpg")
101
98
  end
102
99
 
103
100
  ##
104
101
  # Autoload notification files
105
102
  module Notifier
106
- autoload :Base, File.join(NOTIFIER_PATH, 'base')
107
- autoload :Mail, File.join(NOTIFIER_PATH, 'mail')
108
- autoload :Twitter, File.join(NOTIFIER_PATH, 'twitter')
109
- autoload :Campfire, File.join(NOTIFIER_PATH, 'campfire')
110
- autoload :Prowl, File.join(NOTIFIER_PATH, 'prowl')
111
- autoload :Hipchat, File.join(NOTIFIER_PATH, 'hipchat')
112
- autoload :PagerDuty, File.join(NOTIFIER_PATH, 'pagerduty')
113
- autoload :Pushover, File.join(NOTIFIER_PATH, 'pushover')
114
- autoload :Slack, File.join(NOTIFIER_PATH, 'slack')
115
- autoload :HttpPost, File.join(NOTIFIER_PATH, 'http_post')
116
- autoload :Nagios, File.join(NOTIFIER_PATH, 'nagios')
117
- autoload :FlowDock, File.join(NOTIFIER_PATH, 'flowdock')
118
- autoload :Zabbix, File.join(NOTIFIER_PATH, 'zabbix')
119
- autoload :DataDog, File.join(NOTIFIER_PATH, 'datadog')
120
- autoload :Ses, File.join(NOTIFIER_PATH, 'ses')
121
- autoload :Command, File.join(NOTIFIER_PATH, 'command')
103
+ autoload :Base, File.join(NOTIFIER_PATH, "base")
104
+ autoload :Mail, File.join(NOTIFIER_PATH, "mail")
105
+ autoload :Twitter, File.join(NOTIFIER_PATH, "twitter")
106
+ autoload :Campfire, File.join(NOTIFIER_PATH, "campfire")
107
+ autoload :Prowl, File.join(NOTIFIER_PATH, "prowl")
108
+ autoload :Hipchat, File.join(NOTIFIER_PATH, "hipchat")
109
+ autoload :PagerDuty, File.join(NOTIFIER_PATH, "pagerduty")
110
+ autoload :Pushover, File.join(NOTIFIER_PATH, "pushover")
111
+ autoload :Slack, File.join(NOTIFIER_PATH, "slack")
112
+ autoload :HttpPost, File.join(NOTIFIER_PATH, "http_post")
113
+ autoload :Nagios, File.join(NOTIFIER_PATH, "nagios")
114
+ autoload :FlowDock, File.join(NOTIFIER_PATH, "flowdock")
115
+ autoload :Zabbix, File.join(NOTIFIER_PATH, "zabbix")
116
+ autoload :DataDog, File.join(NOTIFIER_PATH, "datadog")
117
+ autoload :Ses, File.join(NOTIFIER_PATH, "ses")
118
+ autoload :Command, File.join(NOTIFIER_PATH, "command")
122
119
  end
123
120
 
124
121
  ##
125
122
  # Require Backup base files
126
- %w{
123
+ %w[
127
124
  errors
128
125
  logger
129
126
  utilities
@@ -139,6 +136,5 @@ module Backup
139
136
  splitter
140
137
  template
141
138
  version
142
- }.each {|lib| require File.join(LIBRARY_PATH, lib) }
143
-
139
+ ].each { |lib| require File.join(LIBRARY_PATH, lib) }
144
140
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Backup
4
2
  class Archive
5
3
  class Error < Backup::Error; end
@@ -55,45 +53,47 @@ module Backup
55
53
  @model = model
56
54
  @name = name.to_s
57
55
  @options = {
58
- :sudo => false,
59
- :root => false,
60
- :paths => [],
61
- :excludes => [],
62
- :tar_options => ''
56
+ sudo: false,
57
+ root: false,
58
+ paths: [],
59
+ excludes: [],
60
+ tar_options: ""
63
61
  }
64
62
  DSL.new(@options).instance_eval(&block)
65
63
  end
66
64
 
67
65
  def perform!
68
- Logger.info "Creating Archive '#{ name }'..."
66
+ Logger.info "Creating Archive '#{name}'..."
69
67
 
70
- path = File.join(Config.tmp_path, @model.trigger, 'archives')
68
+ path = File.join(Config.tmp_path, @model.trigger, "archives")
71
69
  FileUtils.mkdir_p(path)
72
70
 
73
71
  pipeline = Pipeline.new
74
72
  with_files_from(paths_to_package) do |files_from|
75
73
  pipeline.add(
76
- "#{ tar_command } #{ tar_options } -cPf -#{ tar_root } " +
77
- "#{ paths_to_exclude } #{ files_from }",
74
+ "#{tar_command} #{tar_options} -cPf -#{tar_root} " \
75
+ "#{paths_to_exclude} #{files_from}",
78
76
  tar_success_codes
79
77
  )
80
78
 
81
- extension = 'tar'
82
- @model.compressor.compress_with do |command, ext|
83
- pipeline << command
84
- extension << ext
85
- end if @model.compressor
79
+ extension = "tar"
80
+ if @model.compressor
81
+ @model.compressor.compress_with do |command, ext|
82
+ pipeline << command
83
+ extension << ext
84
+ end
85
+ end
86
86
 
87
- pipeline << "#{ utility(:cat) } > " +
88
- "'#{ File.join(path, "#{ name }.#{ extension }") }'"
87
+ pipeline << "#{utility(:cat)} > " \
88
+ "'#{File.join(path, "#{name}.#{extension}")}'"
89
89
  pipeline.run
90
90
  end
91
91
 
92
92
  if pipeline.success?
93
- Logger.info "Archive '#{ name }' Complete!"
93
+ Logger.info "Archive '#{name}' Complete!"
94
94
  else
95
- raise Error, "Failed to Create Archive '#{ name }'\n" +
96
- pipeline.error_messages
95
+ raise Error, "Failed to Create Archive '#{name}'\n" +
96
+ pipeline.error_messages
97
97
  end
98
98
  end
99
99
 
@@ -101,30 +101,30 @@ module Backup
101
101
 
102
102
  def tar_command
103
103
  tar = utility(:tar)
104
- options[:sudo] ? "#{ utility(:sudo) } -n #{ tar }" : tar
104
+ options[:sudo] ? "#{utility(:sudo)} -n #{tar}" : tar
105
105
  end
106
106
 
107
107
  def tar_root
108
- options[:root] ? " -C '#{ File.expand_path(options[:root]) }'" : ''
108
+ options[:root] ? " -C '#{File.expand_path(options[:root])}'" : ""
109
109
  end
110
110
 
111
111
  def paths_to_package
112
- options[:paths].map {|path| prepare_path(path) }
112
+ options[:paths].map { |path| prepare_path(path) }
113
113
  end
114
114
 
115
115
  def with_files_from(paths)
116
- tmpfile = Tempfile.new('backup-archive-paths')
117
- paths.each {|path| tmpfile.puts path }
116
+ tmpfile = Tempfile.new("backup-archive-paths")
117
+ paths.each { |path| tmpfile.puts path }
118
118
  tmpfile.close
119
- yield "-T '#{ tmpfile.path }'"
119
+ yield "-T '#{tmpfile.path}'"
120
120
  ensure
121
121
  tmpfile.delete
122
122
  end
123
123
 
124
124
  def paths_to_exclude
125
- options[:excludes].map {|path|
126
- "--exclude='#{ prepare_path(path) }'"
127
- }.join(' ')
125
+ options[:excludes].map do |path|
126
+ "--exclude='#{prepare_path(path)}'"
127
+ end.join(" ")
128
128
  end
129
129
 
130
130
  def prepare_path(path)
@@ -133,7 +133,7 @@ module Backup
133
133
 
134
134
  def tar_options
135
135
  args = options[:tar_options]
136
- gnu_tar? ? "--ignore-failed-read #{ args }".strip : args
136
+ gnu_tar? ? "--ignore-failed-read #{args}".strip : args
137
137
  end
138
138
 
139
139
  def tar_success_codes
@@ -165,6 +165,5 @@ module Backup
165
165
  @options[:tar_options] = opts
166
166
  end
167
167
  end
168
-
169
168
  end
170
169
  end
@@ -1,14 +1,11 @@
1
- # encoding: utf-8
2
-
3
1
  module Backup
4
2
  class Binder
5
-
6
3
  ##
7
4
  # Creates a new Backup::Notifier::Binder instance. Loops through the provided
8
5
  # Hash to set instance variables
9
6
  def initialize(key_and_values)
10
7
  key_and_values.each do |key, value|
11
- instance_variable_set("@#{ key }", value)
8
+ instance_variable_set("@#{key}", value)
12
9
  end
13
10
  end
14
11
 
@@ -17,6 +14,5 @@ module Backup
17
14
  def get_binding
18
15
  binding
19
16
  end
20
-
21
17
  end
22
- end
18
+ end
@@ -1,11 +1,8 @@
1
- # encoding: utf-8
2
-
3
1
  module Backup
4
2
  module Cleaner
5
3
  class Error < Backup::Error; end
6
4
 
7
5
  class << self
8
-
9
6
  ##
10
7
  # Logs warnings if any temporary files still exist
11
8
  # from the last time this model/trigger was run,
@@ -17,7 +14,7 @@ module Backup
17
14
  if File.exist?(packaging_folder)
18
15
  messages << <<-EOS
19
16
  The temporary packaging folder still exists!
20
- '#{ packaging_folder }'
17
+ '#{packaging_folder}'
21
18
  It will now be removed.
22
19
  EOS
23
20
  FileUtils.rm_rf(packaging_folder)
@@ -27,23 +24,23 @@ module Backup
27
24
  unless package_files.empty?
28
25
  # the chances of the packaging folder AND
29
26
  # the package files existing are practically nil
30
- messages << ('-' * 74) unless messages.empty?
27
+ messages << ("-" * 74) unless messages.empty?
31
28
 
32
29
  messages << <<-EOS
33
- The temporary backup folder '#{ Config.tmp_path }'
30
+ The temporary backup folder '#{Config.tmp_path}'
34
31
  appears to contain the package files from the previous backup!
35
- #{ package_files.join("\n") }
32
+ #{package_files.join("\n")}
36
33
  These files will now be removed.
37
34
  EOS
38
- package_files.each {|file| FileUtils.rm_f(file) }
35
+ package_files.each { |file| FileUtils.rm_f(file) }
39
36
  end
40
37
 
41
38
  unless messages.empty?
42
39
  Logger.warn Error.new(<<-EOS)
43
40
  Cleanup Warning
44
- #{ messages.join("\n") }
41
+ #{messages.join("\n")}
45
42
  Please check the log for messages and/or your notifications
46
- concerning this backup: '#{ model.label } (#{ model.trigger })'
43
+ concerning this backup: '#{model.label} (#{model.trigger})'
47
44
  The temporary files which had to be removed should not have existed.
48
45
  EOS
49
46
  end
@@ -76,7 +73,7 @@ module Backup
76
73
  if File.exist?(packaging_folder)
77
74
  messages << <<-EOS
78
75
  The temporary packaging folder still exists!
79
- '#{ packaging_folder }'
76
+ '#{packaging_folder}'
80
77
  This folder may contain completed Archives and/or Database backups.
81
78
  EOS
82
79
  end
@@ -85,21 +82,21 @@ module Backup
85
82
  unless package_files.empty?
86
83
  # the chances of the packaging folder AND
87
84
  # the package files existing are practically nil
88
- messages << ('-' * 74) unless messages.empty?
85
+ messages << ("-" * 74) unless messages.empty?
89
86
 
90
87
  messages << <<-EOS
91
- The temporary backup folder '#{ Config.tmp_path }'
88
+ The temporary backup folder '#{Config.tmp_path}'
92
89
  appears to contain the backup files which were to be stored:
93
- #{ package_files.join("\n") }
90
+ #{package_files.join("\n")}
94
91
  EOS
95
92
  end
96
93
 
97
94
  unless messages.empty?
98
95
  Logger.warn Error.new(<<-EOS)
99
96
  Cleanup Warning
100
- #{ messages.join("\n") }
97
+ #{messages.join("\n")}
101
98
  Make sure you check these files before the next scheduled backup for
102
- '#{ model.label } (#{ model.trigger })'
99
+ '#{model.label} (#{model.trigger})'
103
100
  These files will be removed at that time!
104
101
  EOS
105
102
  end
@@ -108,9 +105,8 @@ module Backup
108
105
  private
109
106
 
110
107
  def package_files_for(trigger)
111
- Dir[File.join(Config.tmp_path,"#{ trigger }.tar{,[.-]*}")]
108
+ Dir[File.join(Config.tmp_path, "#{trigger}.tar{,[.-]*}")]
112
109
  end
113
-
114
110
  end
115
111
  end
116
112
  end