backup 3.0.19 → 3.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +9 -8
- data/Gemfile.lock +19 -1
- data/Guardfile +13 -9
- data/README.md +93 -31
- data/backup.gemspec +3 -3
- data/bin/backup +6 -283
- data/lib/backup.rb +101 -72
- data/lib/backup/archive.rb +21 -9
- data/lib/backup/binder.rb +22 -0
- data/lib/backup/cleaner.rb +36 -0
- data/lib/backup/cli/helpers.rb +103 -0
- data/lib/backup/cli/utility.rb +308 -0
- data/lib/backup/compressor/base.rb +2 -2
- data/lib/backup/compressor/pbzip2.rb +76 -0
- data/lib/backup/configuration/compressor/pbzip2.rb +28 -0
- data/lib/backup/configuration/database/riak.rb +25 -0
- data/lib/backup/configuration/encryptor/open_ssl.rb +6 -0
- data/lib/backup/configuration/helpers.rb +5 -18
- data/lib/backup/configuration/notifier/base.rb +13 -0
- data/lib/backup/configuration/notifier/hipchat.rb +41 -0
- data/lib/backup/configuration/notifier/mail.rb +38 -0
- data/lib/backup/configuration/notifier/prowl.rb +23 -0
- data/lib/backup/configuration/storage/cloudfiles.rb +4 -0
- data/lib/backup/configuration/storage/dropbox.rb +8 -4
- data/lib/backup/database/base.rb +10 -2
- data/lib/backup/database/mongodb.rb +16 -19
- data/lib/backup/database/mysql.rb +2 -2
- data/lib/backup/database/postgresql.rb +2 -2
- data/lib/backup/database/redis.rb +15 -7
- data/lib/backup/database/riak.rb +45 -0
- data/lib/backup/dependency.rb +21 -7
- data/lib/backup/encryptor/base.rb +1 -1
- data/lib/backup/encryptor/open_ssl.rb +20 -5
- data/lib/backup/errors.rb +124 -0
- data/lib/backup/finder.rb +11 -3
- data/lib/backup/logger.rb +121 -82
- data/lib/backup/model.rb +103 -44
- data/lib/backup/notifier/base.rb +50 -0
- data/lib/backup/notifier/campfire.rb +32 -52
- data/lib/backup/notifier/hipchat.rb +99 -0
- data/lib/backup/notifier/mail.rb +100 -61
- data/lib/backup/notifier/presently.rb +31 -40
- data/lib/backup/notifier/prowl.rb +73 -0
- data/lib/backup/notifier/twitter.rb +29 -39
- data/lib/backup/packager.rb +25 -0
- data/lib/backup/splitter.rb +62 -0
- data/lib/backup/storage/base.rb +178 -18
- data/lib/backup/storage/cloudfiles.rb +34 -28
- data/lib/backup/storage/dropbox.rb +64 -67
- data/lib/backup/storage/ftp.rb +48 -40
- data/lib/backup/storage/local.rb +33 -28
- data/lib/backup/storage/ninefold.rb +40 -26
- data/lib/backup/storage/object.rb +8 -6
- data/lib/backup/storage/rsync.rb +61 -51
- data/lib/backup/storage/s3.rb +29 -27
- data/lib/backup/storage/scp.rb +56 -36
- data/lib/backup/storage/sftp.rb +49 -33
- data/lib/backup/syncer/base.rb +1 -1
- data/lib/backup/syncer/rsync.rb +1 -1
- data/lib/backup/template.rb +46 -0
- data/lib/backup/version.rb +1 -1
- data/spec/archive_spec.rb +34 -9
- data/spec/backup_spec.rb +1 -1
- data/spec/cli/helpers_spec.rb +35 -0
- data/spec/cli/utility_spec.rb +38 -0
- data/spec/compressor/bzip2_spec.rb +1 -1
- data/spec/compressor/gzip_spec.rb +1 -1
- data/spec/compressor/lzma_spec.rb +1 -1
- data/spec/compressor/pbzip2_spec.rb +63 -0
- data/spec/configuration/base_spec.rb +1 -1
- data/spec/configuration/compressor/bzip2_spec.rb +1 -1
- data/spec/configuration/compressor/gzip_spec.rb +1 -1
- data/spec/configuration/compressor/lzma_spec.rb +1 -1
- data/spec/configuration/database/base_spec.rb +1 -1
- data/spec/configuration/database/mongodb_spec.rb +1 -1
- data/spec/configuration/database/mysql_spec.rb +1 -1
- data/spec/configuration/database/postgresql_spec.rb +1 -1
- data/spec/configuration/database/redis_spec.rb +1 -1
- data/spec/configuration/database/riak_spec.rb +31 -0
- data/spec/configuration/encryptor/gpg_spec.rb +1 -1
- data/spec/configuration/encryptor/open_ssl_spec.rb +4 -1
- data/spec/configuration/notifier/campfire_spec.rb +1 -1
- data/spec/configuration/notifier/hipchat_spec.rb +43 -0
- data/spec/configuration/notifier/mail_spec.rb +34 -22
- data/spec/configuration/notifier/presently_spec.rb +1 -1
- data/spec/configuration/notifier/prowl_spec.rb +28 -0
- data/spec/configuration/notifier/twitter_spec.rb +1 -1
- data/spec/configuration/storage/cloudfiles_spec.rb +19 -16
- data/spec/configuration/storage/dropbox_spec.rb +1 -1
- data/spec/configuration/storage/ftp_spec.rb +1 -1
- data/spec/configuration/storage/local_spec.rb +1 -1
- data/spec/configuration/storage/ninefold_spec.rb +1 -1
- data/spec/configuration/storage/rsync_spec.rb +1 -1
- data/spec/configuration/storage/s3_spec.rb +1 -1
- data/spec/configuration/storage/scp_spec.rb +1 -1
- data/spec/configuration/storage/sftp_spec.rb +1 -1
- data/spec/configuration/syncer/rsync_spec.rb +1 -1
- data/spec/configuration/syncer/s3_spec.rb +1 -1
- data/spec/database/base_spec.rb +10 -1
- data/spec/database/mongodb_spec.rb +34 -7
- data/spec/database/mysql_spec.rb +8 -7
- data/spec/database/postgresql_spec.rb +8 -7
- data/spec/database/redis_spec.rb +39 -9
- data/spec/database/riak_spec.rb +50 -0
- data/spec/encryptor/gpg_spec.rb +1 -1
- data/spec/encryptor/open_ssl_spec.rb +77 -20
- data/spec/errors_spec.rb +306 -0
- data/spec/finder_spec.rb +91 -0
- data/spec/logger_spec.rb +254 -33
- data/spec/model_spec.rb +120 -15
- data/spec/notifier/campfire_spec.rb +127 -52
- data/spec/notifier/hipchat_spec.rb +193 -0
- data/spec/notifier/mail_spec.rb +290 -74
- data/spec/notifier/presently_spec.rb +290 -73
- data/spec/notifier/prowl_spec.rb +149 -0
- data/spec/notifier/twitter_spec.rb +106 -41
- data/spec/spec_helper.rb +8 -2
- data/spec/splitter_spec.rb +71 -0
- data/spec/storage/base_spec.rb +280 -19
- data/spec/storage/cloudfiles_spec.rb +38 -22
- data/spec/storage/dropbox_spec.rb +17 -13
- data/spec/storage/ftp_spec.rb +145 -55
- data/spec/storage/local_spec.rb +6 -6
- data/spec/storage/ninefold_spec.rb +70 -29
- data/spec/storage/object_spec.rb +44 -44
- data/spec/storage/rsync_spec.rb +186 -63
- data/spec/storage/s3_spec.rb +23 -24
- data/spec/storage/scp_spec.rb +116 -41
- data/spec/storage/sftp_spec.rb +124 -46
- data/spec/syncer/rsync_spec.rb +3 -3
- data/spec/syncer/s3_spec.rb +1 -1
- data/spec/version_spec.rb +1 -1
- data/templates/cli/utility/archive +13 -0
- data/{lib/templates → templates/cli/utility}/compressor/bzip2 +1 -1
- data/{lib/templates → templates/cli/utility}/compressor/gzip +1 -1
- data/{lib/templates → templates/cli/utility}/compressor/lzma +0 -0
- data/templates/cli/utility/compressor/pbzip2 +7 -0
- data/templates/cli/utility/config +31 -0
- data/{lib/templates → templates/cli/utility}/database/mongodb +1 -1
- data/{lib/templates → templates/cli/utility}/database/mysql +1 -1
- data/{lib/templates → templates/cli/utility}/database/postgresql +1 -1
- data/{lib/templates → templates/cli/utility}/database/redis +1 -1
- data/templates/cli/utility/database/riak +8 -0
- data/{lib/templates → templates/cli/utility}/encryptor/gpg +1 -1
- data/templates/cli/utility/encryptor/openssl +9 -0
- data/templates/cli/utility/model.erb +23 -0
- data/{lib/templates → templates/cli/utility}/notifier/campfire +2 -1
- data/templates/cli/utility/notifier/hipchat +15 -0
- data/{lib/templates → templates/cli/utility}/notifier/mail +6 -1
- data/{lib/templates → templates/cli/utility}/notifier/presently +1 -0
- data/templates/cli/utility/notifier/prowl +11 -0
- data/{lib/templates → templates/cli/utility}/notifier/twitter +2 -1
- data/templates/cli/utility/splitter +7 -0
- data/templates/cli/utility/storage/cloudfiles +12 -0
- data/{lib/templates → templates/cli/utility}/storage/dropbox +1 -1
- data/{lib/templates → templates/cli/utility}/storage/ftp +0 -0
- data/templates/cli/utility/storage/local +7 -0
- data/{lib/templates → templates/cli/utility}/storage/ninefold +1 -1
- data/templates/cli/utility/storage/rsync +11 -0
- data/{lib/templates → templates/cli/utility}/storage/s3 +0 -2
- data/templates/cli/utility/storage/scp +11 -0
- data/templates/cli/utility/storage/sftp +11 -0
- data/{lib/templates → templates/cli/utility}/syncer/rsync +1 -1
- data/{lib/templates → templates/cli/utility}/syncer/s3 +1 -1
- data/templates/general/links +11 -0
- data/templates/general/version.erb +2 -0
- data/templates/notifier/mail/failure.erb +9 -0
- data/templates/notifier/mail/success.erb +7 -0
- data/templates/notifier/mail/warning.erb +9 -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 +81 -45
- data/lib/backup/cli.rb +0 -110
- data/lib/backup/exception/command_failed.rb +0 -8
- data/lib/backup/exception/command_not_found.rb +0 -8
- data/lib/backup/notifier/binder.rb +0 -32
- data/lib/backup/notifier/templates/notify_failure.erb +0 -33
- data/lib/backup/notifier/templates/notify_success.erb +0 -16
- data/lib/templates/archive +0 -7
- data/lib/templates/encryptor/openssl +0 -8
- data/lib/templates/readme +0 -15
- data/lib/templates/storage/cloudfiles +0 -11
- data/lib/templates/storage/local +0 -7
- data/lib/templates/storage/rsync +0 -11
- data/lib/templates/storage/scp +0 -11
- data/lib/templates/storage/sftp +0 -11
data/spec/syncer/rsync_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require File.
|
3
|
+
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
4
|
|
5
5
|
describe Backup::Syncer::RSync do
|
6
6
|
|
@@ -176,7 +176,7 @@ describe Backup::Syncer::RSync do
|
|
176
176
|
Backup::Logger.expects(:message).with("Backup::Syncer::RSync started syncing '/some/random/directory' '/another/random/directory'.")
|
177
177
|
rsync.expects(:utility).with(:rsync).returns(:rsync)
|
178
178
|
rsync.expects(:remove_password_file!)
|
179
|
-
rsync.expects(:run).with("rsync
|
179
|
+
rsync.expects(:run).with("rsync --archive --delete --compress -e 'ssh -p 22' --password-file='#{rsync.instance_variable_get('@password_file').path}' " +
|
180
180
|
"'/some/random/directory' '/another/random/directory' 'my_username@123.45.678.90:backups/'")
|
181
181
|
rsync.perform!
|
182
182
|
end
|
@@ -186,7 +186,7 @@ describe Backup::Syncer::RSync do
|
|
186
186
|
rsync.password = nil
|
187
187
|
rsync.expects(:utility).with(:rsync).returns(:rsync)
|
188
188
|
rsync.expects(:remove_password_file!)
|
189
|
-
rsync.expects(:run).with("rsync
|
189
|
+
rsync.expects(:run).with("rsync --archive --delete --compress -e 'ssh -p 22' " +
|
190
190
|
"'/some/random/directory' '/another/random/directory' 'my_username@123.45.678.90:backups/'")
|
191
191
|
rsync.perform!
|
192
192
|
end
|
data/spec/syncer/s3_spec.rb
CHANGED
data/spec/version_spec.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
##
|
2
|
+
# Archive [Archive]
|
3
|
+
#
|
4
|
+
archive :my_archive do |archive|
|
5
|
+
# add a file
|
6
|
+
archive.add '/path/to/a/file.rb'
|
7
|
+
# add a folder (including sub-folders)
|
8
|
+
archive.add '/path/to/a/folder/'
|
9
|
+
# exclude a file
|
10
|
+
archive.exclude '/path/to/a/excluded_file.rb'
|
11
|
+
# exclude a folder (including sub-folders)
|
12
|
+
archive.exclude '/path/to/a/excluded_folder/'
|
13
|
+
end
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
##
|
4
|
+
# Backup
|
5
|
+
# Generated Main Config Template
|
6
|
+
#
|
7
|
+
# For more information:
|
8
|
+
#
|
9
|
+
# View the Git repository at https://github.com/meskyanichi/backup
|
10
|
+
# View the Wiki/Documentation at https://github.com/meskyanichi/backup/wiki
|
11
|
+
# View the issue log at https://github.com/meskyanichi/backup/issues
|
12
|
+
|
13
|
+
##
|
14
|
+
# Global Configuration
|
15
|
+
# Add more (or remove) global configuration below
|
16
|
+
Backup::Configuration::Storage::S3.defaults do |s3|
|
17
|
+
# s3.access_key_id = "my_access_key_id"
|
18
|
+
# s3.secret_access_key = "my_secret_access_key"
|
19
|
+
end
|
20
|
+
|
21
|
+
Backup::Configuration::Encryptor::OpenSSL.defaults do |encryption|
|
22
|
+
# encryption.password = "my_password"
|
23
|
+
# encryption.base64 = true
|
24
|
+
# encryption.salt = true
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Load all models from the models directory (after the above global configuration blocks)
|
29
|
+
Dir[File.join(File.dirname(Backup::CONFIG_FILE), "models", "*.rb")].each do |model|
|
30
|
+
instance_eval(File.read(model))
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
##
|
4
|
+
# Backup Generated: <%= @options[:trigger] %>
|
5
|
+
# Once configured, you can run the backup with the following command:
|
6
|
+
#
|
7
|
+
# $ backup perform -t <%= @options[:trigger] %> [-c <path_to_configuration_file>]
|
8
|
+
#
|
9
|
+
Backup::Model.new(:<%= @options[:trigger] %>, 'Description for <%= @options[:trigger] %>') do
|
10
|
+
<% if @options[:splitter] %>
|
11
|
+
<%= Backup::Template.new.result("cli/utility/splitter") %>
|
12
|
+
<% end; if @options[:archives] %>
|
13
|
+
<%= Backup::Template.new.result("cli/utility/archive") %>
|
14
|
+
<% end; [:databases, :storages, :syncers, :encryptors, :compressors, :notifiers].each do |item|
|
15
|
+
if @options[item]
|
16
|
+
@options[item].split(',').map(&:strip).uniq.each do |entry|
|
17
|
+
if File.exist?(File.join(Backup::TEMPLATE_PATH, 'cli', 'utility', item.to_s[0..-2], entry)) %>
|
18
|
+
<%= Backup::Template.new.result("cli/utility/#{item.to_s[0..-2]}/#{entry}") %>
|
19
|
+
<% end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end %>
|
23
|
+
end
|
@@ -3,9 +3,10 @@
|
|
3
3
|
#
|
4
4
|
notify_by Campfire do |campfire|
|
5
5
|
campfire.on_success = true
|
6
|
+
campfire.on_warning = true
|
6
7
|
campfire.on_failure = true
|
7
8
|
|
8
9
|
campfire.api_token = 'my_api_authentication_token'
|
9
10
|
campfire.subdomain = 'my_subdomain'
|
10
11
|
campfire.room_id = 'my_room_id'
|
11
|
-
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
##
|
2
|
+
# Hipchat [Notifier]
|
3
|
+
#
|
4
|
+
notify_by Hipchat do |hipchat|
|
5
|
+
hipchat.on_success = true
|
6
|
+
hipchat.on_warning = true
|
7
|
+
hipchat.on_failure = true
|
8
|
+
|
9
|
+
hipchat.token = 'token'
|
10
|
+
hipchat.from = 'DB Backup'
|
11
|
+
hipchat.rooms_notified = ['activity']
|
12
|
+
hipchat.success_color = 'green'
|
13
|
+
hipchat.warning_color = 'yellow'
|
14
|
+
hipchat.failure_color = 'red'
|
15
|
+
end
|
@@ -1,8 +1,13 @@
|
|
1
1
|
##
|
2
2
|
# Mail [Notifier]
|
3
3
|
#
|
4
|
+
# The default delivery method for Mail Notifiers is 'SMTP'.
|
5
|
+
# See the Wiki for other delivery options.
|
6
|
+
# https://github.com/meskyanichi/backup/wiki/Notifiers
|
7
|
+
#
|
4
8
|
notify_by Mail do |mail|
|
5
9
|
mail.on_success = true
|
10
|
+
mail.on_warning = true
|
6
11
|
mail.on_failure = true
|
7
12
|
|
8
13
|
mail.from = 'sender@email.com'
|
@@ -14,4 +19,4 @@
|
|
14
19
|
mail.password = 'my_password'
|
15
20
|
mail.authentication = 'plain'
|
16
21
|
mail.enable_starttls_auto = true
|
17
|
-
end
|
22
|
+
end
|
@@ -3,10 +3,11 @@
|
|
3
3
|
#
|
4
4
|
notify_by Twitter do |tweet|
|
5
5
|
tweet.on_success = true
|
6
|
+
tweet.on_warning = true
|
6
7
|
tweet.on_failure = true
|
7
8
|
|
8
9
|
tweet.consumer_key = 'my_consumer_key'
|
9
10
|
tweet.consumer_secret = 'my_consumer_secret'
|
10
11
|
tweet.oauth_token = 'my_oauth_token'
|
11
12
|
tweet.oauth_token_secret = 'my_oauth_token_secret'
|
12
|
-
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
##
|
2
|
+
# Rackspace Cloud Files [Storage]
|
3
|
+
#
|
4
|
+
store_with CloudFiles do |cf|
|
5
|
+
cf.api_key = 'my_api_key'
|
6
|
+
cf.username = 'my_username'
|
7
|
+
cf.container = 'my_container'
|
8
|
+
cf.path = '/path/to/my/backups'
|
9
|
+
cf.keep = 5
|
10
|
+
cf.auth_url = 'lon.auth.api.rackspacecloud.com'
|
11
|
+
cf.servicenet = false
|
12
|
+
end
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
##
|
2
|
+
# SFTP (Secure File Transfer Protocol) [Storage]
|
3
|
+
#
|
4
|
+
store_with SFTP do |server|
|
5
|
+
server.username = 'my_username'
|
6
|
+
server.password = 'my_password'
|
7
|
+
server.ip = '123.45.678.90'
|
8
|
+
server.port = 22
|
9
|
+
server.path = '~/backups/'
|
10
|
+
server.keep = 5
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Backup's Ruby Gem releases:
|
2
|
+
http://rubygems.org/gems/backup
|
3
|
+
|
4
|
+
Backup's Git repository:
|
5
|
+
https://github.com/meskyanichi/backup
|
6
|
+
|
7
|
+
Backup's Issue Tracker:
|
8
|
+
https://github.com/meskyanichi/backup/issues
|
9
|
+
|
10
|
+
Backup's Wikipedia/Documentation/Guides:
|
11
|
+
https://github.com/meskyanichi/backup/wiki
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
Backup <%= @model.label %> (<%= @model.trigger %>) Failed!
|
3
|
+
|
4
|
+
See the attached backup log for details.
|
5
|
+
|
6
|
+
===========================================================================
|
7
|
+
<%= Backup::Template.new.result("general/version.erb") %>
|
8
|
+
|
9
|
+
<%= Backup::Template.new.result("general/links") %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
Backup <%= @model.label %> (<%= @model.trigger %>) finished without any errors!
|
3
|
+
|
4
|
+
===========================================================================
|
5
|
+
<%= Backup::Template.new.result("general/version.erb") %>
|
6
|
+
|
7
|
+
<%= Backup::Template.new.result("general/links") %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
Backup <%= @model.label %> (<%= @model.trigger %>) finished with warnings.
|
3
|
+
|
4
|
+
See the attached backup log for details.
|
5
|
+
|
6
|
+
===========================================================================
|
7
|
+
<%= Backup::Template.new.result("general/version.erb") %>
|
8
|
+
|
9
|
+
<%= Backup::Template.new.result("general/links") %>
|