backup 4.4.1 → 5.0.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +19 -0
  3. data/README.md +13 -9
  4. data/bin/docker_test +24 -0
  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/dsl.rb +16 -17
  17. data/lib/backup/config/helpers.rb +10 -16
  18. data/lib/backup/config.rb +17 -18
  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/console.rb +5 -8
  32. data/lib/backup/logger/fog_adapter.rb +2 -6
  33. data/lib/backup/logger/logfile.rb +10 -12
  34. data/lib/backup/logger/syslog.rb +2 -4
  35. data/lib/backup/logger.rb +16 -18
  36. data/lib/backup/model.rb +33 -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 +42 -59
  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 +14 -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 +78 -69
  79. data/lib/backup/version.rb +1 -3
  80. data/lib/backup.rb +74 -78
  81. metadata +107 -676
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27f2f7a25217955273c6b721509dacde87c0ba06715004ee3cf732262a4e3fed
4
- data.tar.gz: ee514abc68b3d0ecb52f6965b14dac5d6ac8d17386a5ae8ef46029cf6aa332a3
3
+ metadata.gz: be84fcf585977ffff359b7f8b1052b87d6fd505fdf7b2324a7f309ec41bf8007
4
+ data.tar.gz: f46f2e94686a50cab3ee91ef64320aab6a5a7f249069906f52c9f37bc9fa371c
5
5
  SHA512:
6
- metadata.gz: 0015adf0f7e1b5e226866a11cdd658c129853508df5301c9df641fd377e55e9c73271577aca41d4d57178ba67238f9cd39d2fbce82fe6f89052f1977292138c3
7
- data.tar.gz: d338cf0df9fc344c283aa14cc31e17ebe912e51f49e210ab873941986548c56af72a3acccb0dc259131c12727c5d6957eb535bbad52a11667a399799a5bd2d24
6
+ metadata.gz: 1fcf15d44034f42fdbc319e1754c2df3a8b9b61f3658a753d0bc576fc000b185ebfb897cb77543dae86a785a0ae192b996eba05e6ca6043cdd4028db9ec77a6d
7
+ data.tar.gz: 103d3d83c801d70ac6f249e4a9bb1720aa0decb4475d37f722f6628ee16c5b38d9940048c30880c5c8f9555eb3c9e9c575e5a464c4d7e0509987aa027ac63c56
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
@@ -1,29 +1,33 @@
1
- Backup v4.x
2
- ===========
1
+ Backup
2
+ ======
3
3
 
4
- [![Code Climate](https://codeclimate.com/github/backup/backup.png)](https://codeclimate.com/github/backup/backup)
4
+ [![Code Climate](https://codeclimate.com/github/backup/backup.svg)](https://codeclimate.com/github/backup/backup)
5
5
  [![Build Status](https://travis-ci.org/backup/backup.svg?branch=master)](https://travis-ci.org/backup/backup)
6
6
  [![Join the chat at https://gitter.im/backup/backup](https://badges.gitter.im/Join%20Chat.svg)][Gitter]
7
7
 
8
+ > This project is now in maintenance. No new features are planned.
9
+
8
10
  Backup is a system utility for Linux and Mac OS X, distributed as a RubyGem, that allows you to easily perform backup
9
11
  operations. It provides an elegant DSL in Ruby for _modeling_ your backups. Backup has built-in support for various
10
12
  databases, storage protocols/services, syncers, compressors, encryptors and notifiers which you can mix and match. It
11
13
  was built with modularity, extensibility and simplicity in mind.
12
14
 
13
- [Installation][] · [Release Notes][] · [Documentation][] · [Issues][] · [Features][] · [Chat][Gitter]
15
+ [Installation][] · [Release Notes][] · [Documentation][] · [Issues][] · [Chat][Gitter]
16
+
17
+ ## Project Status: Maintenance-Only ##
18
+
19
+ This project is not under active development, although we will continue to provide support for current users, and at least one more maintenance release: version 5.0. The version 5.0 release will include support for Ruby 2.4, and various other fixes. Future releases of Backup will only include bug fixes.
14
20
 
15
- Please use the Backup features [issue tracker][Features] to suggest new features.
16
- Only use the Backup gem [issue tracker][Issues] for bugs and other issues.
17
- We're also available on [Gitter] for questions and problems.
21
+ If you use this project and would like to develop it further, please introduce yourself on the [maintainers wanted][Maintainers wanted] ticket.
18
22
 
19
- **Copyright (c) 2009-2016 [Michael van Rooijen][] ( [@mrrooijen] )**
23
+ **Copyright (c) 2009-2017 [Michael van Rooijen][] ( [@mrrooijen] )**
20
24
  Released under the **MIT** [LICENSE](LICENSE).
21
25
 
22
26
  [Installation]: http://backup.github.io/backup/v4/installation
23
27
  [Release Notes]: http://backup.github.io/backup/v4/release-notes
24
28
  [Documentation]: http://backup.github.io/backup/v4
25
29
  [Issues]: https://github.com/backup/backup/issues
26
- [Features]: https://github.com/backup/backup-features/issues
27
30
  [Gitter]: https://gitter.im/backup/backup?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
31
+ [Maintainers wanted]: https://github.com/backup/backup/issues/803
28
32
  [Michael van Rooijen]: http://github.com/mrrooijen
29
33
  [@mrrooijen]: http://twitter.com/mrrooijen
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
@@ -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
data/lib/backup/binder.rb CHANGED
@@ -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