backup 3.0.15 → 3.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -2
- data/Gemfile.lock +21 -10
- data/Guardfile +17 -0
- data/README.md +87 -42
- data/backup.gemspec +1 -9
- data/lib/backup.rb +6 -2
- data/lib/backup/archive.rb +1 -1
- data/lib/backup/cli.rb +1 -1
- data/lib/backup/compressor/bzip2.rb +64 -0
- data/lib/backup/configuration/compressor/bzip2.rb +23 -0
- data/lib/backup/configuration/notifier/presently.rb +25 -0
- data/lib/backup/encryptor/gpg.rb +1 -1
- data/lib/backup/notifier/presently.rb +105 -0
- data/lib/backup/storage/s3.rb +2 -6
- data/lib/backup/syncer/s3.rb +6 -4
- data/lib/backup/version.rb +1 -1
- data/lib/templates/archive +3 -0
- data/lib/templates/compressor/bzip2 +7 -0
- data/lib/templates/compressor/gzip +3 -0
- data/lib/templates/database/mongodb +3 -0
- data/lib/templates/database/mysql +3 -0
- data/lib/templates/database/postgresql +4 -1
- data/lib/templates/database/redis +3 -0
- data/lib/templates/encryptor/gpg +3 -0
- data/lib/templates/encryptor/openssl +3 -0
- data/lib/templates/notifier/campfire +3 -0
- data/lib/templates/notifier/mail +3 -0
- data/lib/templates/notifier/presently +12 -0
- data/lib/templates/notifier/twitter +3 -0
- data/lib/templates/readme +1 -1
- data/lib/templates/storage/cloudfiles +3 -0
- data/lib/templates/storage/dropbox +3 -0
- data/lib/templates/storage/ftp +3 -0
- data/lib/templates/storage/rsync +3 -0
- data/lib/templates/storage/s3 +14 -1
- data/lib/templates/storage/scp +3 -0
- data/lib/templates/storage/sftp +3 -0
- data/lib/templates/syncer/rsync +3 -0
- data/lib/templates/syncer/s3 +3 -0
- data/spec/archive_spec.rb +4 -4
- data/spec/compressor/bzip2_spec.rb +59 -0
- data/spec/encryptor/gpg_spec.rb +10 -10
- data/spec/notifier/presently_spec.rb +99 -0
- data/spec/spec_helper.rb +4 -0
- metadata +15 -7
- data/.infinity_test +0 -7
- data/.rspec +0 -3
data/spec/archive_spec.rb
CHANGED
@@ -9,8 +9,8 @@ describe Backup::Archive do
|
|
9
9
|
a.add '/home/rspecuser/somefile'
|
10
10
|
a.add '/home/rspecuser/logs/'
|
11
11
|
a.add '/home/rspecuser/dotfiles/'
|
12
|
-
a.exclude '/home/rspecuser/
|
13
|
-
a.exclude '/home/rspecuser/
|
12
|
+
a.exclude '/home/rspecuser/badfile'
|
13
|
+
a.exclude '/home/rspecuser/wrongdir/'
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -51,7 +51,7 @@ describe Backup::Archive do
|
|
51
51
|
|
52
52
|
it 'should return a tar -c friendly string' do
|
53
53
|
archive.send(:paths_to_exclude).should ==
|
54
|
-
"--exclude=
|
54
|
+
"--exclude='/home/rspecuser/badfile' --exclude='/home/rspecuser/wrongdir/'"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -64,7 +64,7 @@ describe Backup::Archive do
|
|
64
64
|
context 'when both paths were added and paths that should be excluded were added' do
|
65
65
|
it 'should render both the syntax for the paths that be included as well as excluded' do
|
66
66
|
archive.expects(:mkdir).with(File.join(Backup::TMP_PATH, Backup::TRIGGER, 'archive'))
|
67
|
-
archive.expects(:run).with("tar -c -f '#{File.join(Backup::TMP_PATH, Backup::TRIGGER, 'archive', "#{:dummy_archive}.tar")}' --exclude=
|
67
|
+
archive.expects(:run).with("tar -c -f '#{File.join(Backup::TMP_PATH, Backup::TRIGGER, 'archive', "#{:dummy_archive}.tar")}' --exclude='/home/rspecuser/badfile' --exclude='/home/rspecuser/wrongdir/' '/home/rspecuser/somefile' '/home/rspecuser/logs/' '/home/rspecuser/dotfiles/' 2> /dev/null")
|
68
68
|
archive.expects(:utility).with(:tar).returns(:tar)
|
69
69
|
archive.perform!
|
70
70
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
|
5
|
+
describe Backup::Compressor::Bzip2 do
|
6
|
+
let(:compressor) { Backup::Compressor::Bzip2.new }
|
7
|
+
|
8
|
+
before do
|
9
|
+
Backup::Model.extension = 'tar'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'the options' do
|
13
|
+
it do
|
14
|
+
compressor.send(:best).should == []
|
15
|
+
end
|
16
|
+
|
17
|
+
it do
|
18
|
+
compressor.send(:fast).should == []
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#perform!' do
|
23
|
+
before do
|
24
|
+
[:run, :utility].each { |method| compressor.stubs(method) }
|
25
|
+
Backup::Logger.stubs(:message)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should perform the compression' do
|
29
|
+
compressor.expects(:utility).with(:bzip2).returns(:bzip2)
|
30
|
+
compressor.expects(:run).with("bzip2 '#{ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar") }'")
|
31
|
+
compressor.perform!
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should perform the compression with the --best and --fast options' do
|
35
|
+
compressor = Backup::Compressor::Bzip2.new do |c|
|
36
|
+
c.best = true
|
37
|
+
c.fast = true
|
38
|
+
end
|
39
|
+
|
40
|
+
compressor.stubs(:utility).returns(:bzip2)
|
41
|
+
compressor.expects(:run).with("bzip2 --best --fast '#{ File.join(Backup::TMP_PATH, "#{ Backup::TIME }.#{ Backup::TRIGGER }.tar") }'")
|
42
|
+
compressor.perform!
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should set the class variable @extension (Backup::Model.extension) to .bz2' do
|
46
|
+
compressor.stubs(:utility).returns(:bzip2)
|
47
|
+
compressor.expects(:run)
|
48
|
+
|
49
|
+
Backup::Model.extension.should == 'tar'
|
50
|
+
compressor.perform!
|
51
|
+
Backup::Model.extension.should == 'tar.bz2'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should log' do
|
55
|
+
Backup::Logger.expects(:message).with("Backup::Compressor::Bzip2 started compressing the archive.")
|
56
|
+
compressor.perform!
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/encryptor/gpg_spec.rb
CHANGED
@@ -20,19 +20,19 @@ describe Backup::Encryptor::GPG do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
context "when a block is provided" do
|
23
|
-
it do
|
23
|
+
it "should strip initial whitespace from key lines" do
|
24
24
|
key = <<-KEY
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
26
|
+
Version: GnuPG v1.4.11 (Darwin)
|
27
|
+
|
28
|
+
mQENBE12G/8BCAC4mnlSMYMBwBYTHe5zURcnYYNCORPWOr0iXGiLWuKxYtrDQyLm
|
29
|
+
X2Nws44Iz7Wp7AuJRAjkitf1cRBgXyDu8wuogXO7JqPmtsUdBCABz9w5NH6IQjgR
|
30
|
+
WNa3g2n0nokA7Zr5FA4GXoEaYivfbvGiyNpd6P4okH+//G2p+3FIryu5xz+89D1b
|
31
|
+
=Yvhg
|
32
|
+
-----END PGP PUBLIC KEY BLOCK-----
|
33
33
|
KEY
|
34
34
|
|
35
|
-
encryptor.key.should == key
|
35
|
+
encryptor.key.should == key
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
4
|
+
|
5
|
+
describe Backup::Notifier::Presently do
|
6
|
+
let(:notifier) do
|
7
|
+
Backup::Notifier::Presently.new do |presently|
|
8
|
+
presently.user_name = 'user_name'
|
9
|
+
presently.subdomain = 'subdomain'
|
10
|
+
presently.password = 'password'
|
11
|
+
presently.group_id = 'group_id'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it do
|
16
|
+
notifier.user_name.should == 'user_name'
|
17
|
+
notifier.subdomain.should == 'subdomain'
|
18
|
+
notifier.password.should == 'password'
|
19
|
+
notifier.group_id.should == 'group_id'
|
20
|
+
|
21
|
+
notifier.on_success.should == true
|
22
|
+
notifier.on_failure.should == true
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'defaults' do
|
26
|
+
it do
|
27
|
+
Backup::Configuration::Notifier::Presently.defaults do |presently|
|
28
|
+
presently.user_name = 'old_user_name'
|
29
|
+
presently.on_success = false
|
30
|
+
presently.on_failure = true
|
31
|
+
end
|
32
|
+
notifier = Backup::Notifier::Presently.new do |presently|
|
33
|
+
presently.user_name = 'new_user_name'
|
34
|
+
end
|
35
|
+
|
36
|
+
notifier.user_name.should == 'new_user_name'
|
37
|
+
notifier.on_success.should == false
|
38
|
+
notifier.on_failure.should == true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#initialize' do
|
43
|
+
it do
|
44
|
+
Backup::Notifier::Presently.any_instance.expects(:set_defaults!)
|
45
|
+
Backup::Notifier::Presently.new
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#perform!' do
|
50
|
+
let(:model) { Backup::Model.new('blah', 'blah') {} }
|
51
|
+
before do
|
52
|
+
notifier.on_success = false
|
53
|
+
notifier.on_failure = false
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when successful" do
|
57
|
+
it do
|
58
|
+
Backup::Logger.expects(:message).with("Backup::Notifier::Presently started notifying about the process.")
|
59
|
+
notifier.expects("notify_success!")
|
60
|
+
notifier.on_success = true
|
61
|
+
notifier.perform!(model)
|
62
|
+
end
|
63
|
+
|
64
|
+
it do
|
65
|
+
notifier.expects("notify_success!").never
|
66
|
+
notifier.on_success = false
|
67
|
+
notifier.perform!(model)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when failed" do
|
72
|
+
it do
|
73
|
+
Backup::Logger.expects(:message).with("Backup::Notifier::Presently started notifying about the process.")
|
74
|
+
notifier.expects("notify_failure!")
|
75
|
+
notifier.on_failure = true
|
76
|
+
notifier.perform!(model, Exception.new)
|
77
|
+
end
|
78
|
+
|
79
|
+
it do
|
80
|
+
notifier.expects("notify_failure!").never
|
81
|
+
notifier.on_failure = false
|
82
|
+
notifier.perform!(model, Exception.new)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe Backup::Notifier::Presently::Client do
|
88
|
+
let(:client) do
|
89
|
+
Backup::Notifier::Presently::Client.new('subdomain', 'user_name', 'password', 'group_id')
|
90
|
+
end
|
91
|
+
|
92
|
+
it do
|
93
|
+
client.user_name.should == 'user_name'
|
94
|
+
client.subdomain.should == 'subdomain'
|
95
|
+
client.password.should == 'password'
|
96
|
+
client.group_id.should == 'group_id'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.0.
|
5
|
+
version: 3.0.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael van Rooijen
|
@@ -10,7 +10,8 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-03 00:00:00 +02:00
|
14
|
+
default_executable:
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: thor
|
@@ -33,10 +34,9 @@ extra_rdoc_files: []
|
|
33
34
|
|
34
35
|
files:
|
35
36
|
- .gitignore
|
36
|
-
- .infinity_test
|
37
|
-
- .rspec
|
38
37
|
- Gemfile
|
39
38
|
- Gemfile.lock
|
39
|
+
- Guardfile
|
40
40
|
- LICENSE.md
|
41
41
|
- README.md
|
42
42
|
- backup.gemspec
|
@@ -45,9 +45,11 @@ files:
|
|
45
45
|
- lib/backup/archive.rb
|
46
46
|
- lib/backup/cli.rb
|
47
47
|
- lib/backup/compressor/base.rb
|
48
|
+
- lib/backup/compressor/bzip2.rb
|
48
49
|
- lib/backup/compressor/gzip.rb
|
49
50
|
- lib/backup/configuration/base.rb
|
50
51
|
- lib/backup/configuration/compressor/base.rb
|
52
|
+
- lib/backup/configuration/compressor/bzip2.rb
|
51
53
|
- lib/backup/configuration/compressor/gzip.rb
|
52
54
|
- lib/backup/configuration/database/base.rb
|
53
55
|
- lib/backup/configuration/database/mongodb.rb
|
@@ -61,6 +63,7 @@ files:
|
|
61
63
|
- lib/backup/configuration/notifier/base.rb
|
62
64
|
- lib/backup/configuration/notifier/campfire.rb
|
63
65
|
- lib/backup/configuration/notifier/mail.rb
|
66
|
+
- lib/backup/configuration/notifier/presently.rb
|
64
67
|
- lib/backup/configuration/notifier/twitter.rb
|
65
68
|
- lib/backup/configuration/storage/base.rb
|
66
69
|
- lib/backup/configuration/storage/cloudfiles.rb
|
@@ -89,6 +92,7 @@ files:
|
|
89
92
|
- lib/backup/notifier/binder.rb
|
90
93
|
- lib/backup/notifier/campfire.rb
|
91
94
|
- lib/backup/notifier/mail.rb
|
95
|
+
- lib/backup/notifier/presently.rb
|
92
96
|
- lib/backup/notifier/templates/notify_failure.erb
|
93
97
|
- lib/backup/notifier/templates/notify_success.erb
|
94
98
|
- lib/backup/notifier/twitter.rb
|
@@ -106,6 +110,7 @@ files:
|
|
106
110
|
- lib/backup/syncer/s3.rb
|
107
111
|
- lib/backup/version.rb
|
108
112
|
- lib/templates/archive
|
113
|
+
- lib/templates/compressor/bzip2
|
109
114
|
- lib/templates/compressor/gzip
|
110
115
|
- lib/templates/database/mongodb
|
111
116
|
- lib/templates/database/mysql
|
@@ -115,6 +120,7 @@ files:
|
|
115
120
|
- lib/templates/encryptor/openssl
|
116
121
|
- lib/templates/notifier/campfire
|
117
122
|
- lib/templates/notifier/mail
|
123
|
+
- lib/templates/notifier/presently
|
118
124
|
- lib/templates/notifier/twitter
|
119
125
|
- lib/templates/readme
|
120
126
|
- lib/templates/storage/cloudfiles
|
@@ -128,6 +134,7 @@ files:
|
|
128
134
|
- lib/templates/syncer/s3
|
129
135
|
- spec/archive_spec.rb
|
130
136
|
- spec/backup_spec.rb
|
137
|
+
- spec/compressor/bzip2_spec.rb
|
131
138
|
- spec/compressor/gzip_spec.rb
|
132
139
|
- spec/configuration/base_spec.rb
|
133
140
|
- spec/configuration/compressor/gzip_spec.rb
|
@@ -161,6 +168,7 @@ files:
|
|
161
168
|
- spec/model_spec.rb
|
162
169
|
- spec/notifier/campfire_spec.rb
|
163
170
|
- spec/notifier/mail_spec.rb
|
171
|
+
- spec/notifier/presently_spec.rb
|
164
172
|
- spec/notifier/twitter_spec.rb
|
165
173
|
- spec/spec_helper.rb
|
166
174
|
- spec/storage/base_spec.rb
|
@@ -175,6 +183,7 @@ files:
|
|
175
183
|
- spec/syncer/rsync_spec.rb
|
176
184
|
- spec/syncer/s3_spec.rb
|
177
185
|
- spec/version_spec.rb
|
186
|
+
has_rdoc: true
|
178
187
|
homepage: http://rubygems.org/gems/backup
|
179
188
|
licenses: []
|
180
189
|
|
@@ -198,10 +207,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
207
|
requirements: []
|
199
208
|
|
200
209
|
rubyforge_project:
|
201
|
-
rubygems_version: 1.
|
210
|
+
rubygems_version: 1.6.2
|
202
211
|
signing_key:
|
203
212
|
specification_version: 3
|
204
|
-
summary:
|
213
|
+
summary: Backup is a RubyGem, written for Linux and Mac OSX, that allows you to easily perform backup operations on both your remote, as well as your local environment. It provides you with an elegant DSL in Ruby for modeling (configuring) your backups. Backup has built-in support for various databases, storage protocols/services, syncers, compressors, encryptors and notifiers which you can mix and match. It was built with modularity, extensibility and simplicity in mind.
|
205
214
|
test_files: []
|
206
215
|
|
207
|
-
has_rdoc:
|
data/.infinity_test
DELETED
data/.rspec
DELETED