webtranslateit-safe 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +445 -32
- data/CHANGELOG +4 -5
- data/Gemfile.lock +1 -1
- data/bin/webtranslateit-safe +16 -16
- data/lib/webtranslateit/safe/archive.rb +4 -9
- data/lib/webtranslateit/safe/backup.rb +2 -9
- data/lib/webtranslateit/safe/cloudfiles.rb +1 -1
- data/lib/webtranslateit/safe/config/builder.rb +6 -16
- data/lib/webtranslateit/safe/config/node.rb +14 -21
- data/lib/webtranslateit/safe/ftp.rb +26 -26
- data/lib/webtranslateit/safe/gpg.rb +2 -8
- data/lib/webtranslateit/safe/gzip.rb +1 -5
- data/lib/webtranslateit/safe/local.rb +12 -16
- data/lib/webtranslateit/safe/mongodump.rb +6 -13
- data/lib/webtranslateit/safe/mysqldump.rb +5 -9
- data/lib/webtranslateit/safe/pgdump.rb +9 -9
- data/lib/webtranslateit/safe/pipe.rb +0 -6
- data/lib/webtranslateit/safe/s3.rb +1 -1
- data/lib/webtranslateit/safe/sftp.rb +25 -33
- data/lib/webtranslateit/safe/sink.rb +4 -9
- data/lib/webtranslateit/safe/source.rb +9 -13
- data/lib/webtranslateit/safe/stream.rb +6 -14
- data/lib/webtranslateit/safe/svndump.rb +1 -5
- data/lib/webtranslateit/safe/tmp_file.rb +11 -16
- data/lib/webtranslateit/safe/version.rb +1 -5
- data/lib/webtranslateit/safe.rb +9 -11
- data/spec/webtranslateit/safe/archive_spec.rb +20 -20
- data/spec/webtranslateit/safe/cloudfiles_spec.rb +1 -1
- data/spec/webtranslateit/safe/config_spec.rb +31 -31
- data/spec/webtranslateit/safe/gpg_spec.rb +35 -35
- data/spec/webtranslateit/safe/gzip_spec.rb +11 -11
- data/spec/webtranslateit/safe/local_spec.rb +27 -27
- data/spec/webtranslateit/safe/mongodump_spec.rb +23 -23
- data/spec/webtranslateit/safe/mysqldump_spec.rb +30 -30
- data/spec/webtranslateit/safe/pgdump_spec.rb +13 -13
- data/spec/webtranslateit/safe/s3_spec.rb +1 -1
- data/spec/webtranslateit/safe/svndump_spec.rb +9 -9
- data/webtranslateit-safe.gemspec +6 -7
- metadata +2 -2
@@ -3,10 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe WebTranslateIt::Safe::Gpg do
|
4
4
|
def def_backup
|
5
5
|
{
|
6
|
-
compressed
|
7
|
-
command
|
8
|
-
extension
|
9
|
-
filename
|
6
|
+
:compressed => false,
|
7
|
+
:command => 'command',
|
8
|
+
:extension => '.foo',
|
9
|
+
:filename => 'qweqwe'
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
@@ -22,27 +22,27 @@ describe WebTranslateIt::Safe::Gpg do
|
|
22
22
|
describe :process do
|
23
23
|
|
24
24
|
before(:each) do
|
25
|
-
@gpg = gpg
|
26
|
-
stub(@gpg).gpg_password_file {
|
27
|
-
stub(@gpg).pipe {
|
25
|
+
@gpg = gpg()
|
26
|
+
stub(@gpg).gpg_password_file {'pwd-file'}
|
27
|
+
stub(@gpg).pipe {'|gpg -BLAH'}
|
28
28
|
end
|
29
29
|
|
30
30
|
describe 'when active' do
|
31
31
|
before(:each) do
|
32
|
-
stub(@gpg).active? {
|
32
|
+
stub(@gpg).active? {true}
|
33
33
|
end
|
34
34
|
|
35
|
-
it '
|
35
|
+
it 'should add .gpg extension' do
|
36
36
|
mock(@gpg.backup.extension) << '.gpg'
|
37
37
|
@gpg.process
|
38
38
|
end
|
39
39
|
|
40
|
-
it '
|
40
|
+
it 'should add command pipe' do
|
41
41
|
mock(@gpg.backup.command) << (/\|gpg -BLAH/)
|
42
42
|
@gpg.process
|
43
43
|
end
|
44
44
|
|
45
|
-
it '
|
45
|
+
it 'should set compressed' do
|
46
46
|
mock(@gpg.backup).compressed = true
|
47
47
|
@gpg.process
|
48
48
|
end
|
@@ -50,20 +50,20 @@ describe WebTranslateIt::Safe::Gpg do
|
|
50
50
|
|
51
51
|
describe 'when inactive' do
|
52
52
|
before(:each) do
|
53
|
-
stub(@gpg).active? {
|
53
|
+
stub(@gpg).active? {false}
|
54
54
|
end
|
55
55
|
|
56
|
-
it '
|
56
|
+
it 'should not touch extension' do
|
57
57
|
dont_allow(@gpg.backup.extension) << anything
|
58
58
|
@gpg.process
|
59
59
|
end
|
60
60
|
|
61
|
-
it '
|
61
|
+
it 'should not touch command' do
|
62
62
|
dont_allow(@gpg.backup.command) << anything
|
63
63
|
@gpg.process
|
64
64
|
end
|
65
65
|
|
66
|
-
it '
|
66
|
+
it 'should not touch compressed' do
|
67
67
|
dont_allow(@gpg.backup).compressed = anything
|
68
68
|
@gpg.process
|
69
69
|
end
|
@@ -73,27 +73,27 @@ describe WebTranslateIt::Safe::Gpg do
|
|
73
73
|
describe :active? do
|
74
74
|
|
75
75
|
describe 'with key' do
|
76
|
-
it '
|
77
|
-
expect(gpg(gpg
|
76
|
+
it 'should be true' do
|
77
|
+
expect(gpg(:gpg => {:key => :foo}).active?).to be_truthy
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
describe 'with password' do
|
82
|
-
it '
|
83
|
-
expect(gpg(gpg
|
82
|
+
it 'should be true' do
|
83
|
+
expect(gpg(:gpg => {:password => :foo}).active?).to be_truthy
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
87
|
describe 'without key & password' do
|
88
|
-
it '
|
89
|
-
expect(gpg).
|
88
|
+
it 'should be false' do
|
89
|
+
expect(gpg.active?).to be_falsy
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe 'with key & password' do
|
94
|
-
it '
|
94
|
+
it 'should raise RuntimeError' do
|
95
95
|
lambda {
|
96
|
-
gpg(gpg
|
96
|
+
gpg(:gpg => {:key => 'foo', :password => 'bar'}).send :active?
|
97
97
|
}.should raise_error(RuntimeError, "can't use both gpg password and pubkey")
|
98
98
|
end
|
99
99
|
end
|
@@ -102,44 +102,44 @@ describe WebTranslateIt::Safe::Gpg do
|
|
102
102
|
describe :pipe do
|
103
103
|
|
104
104
|
describe 'with key' do
|
105
|
-
def kgpg(extra
|
106
|
-
gpg({gpg
|
105
|
+
def kgpg(extra={})
|
106
|
+
gpg({:gpg => {:key => 'foo', :options => 'GPG-OPT'}.merge(extra), :options => 'OPT'})
|
107
107
|
end
|
108
108
|
|
109
|
-
it '
|
109
|
+
it 'should not call gpg_password_file' do
|
110
110
|
g = kgpg
|
111
111
|
dont_allow(g).gpg_password_file(anything)
|
112
112
|
g.send(:pipe)
|
113
113
|
end
|
114
114
|
|
115
|
-
it "
|
115
|
+
it "should use '-r' and :options" do
|
116
116
|
kgpg.send(:pipe).should == '|gpg GPG-OPT -e -r foo'
|
117
117
|
end
|
118
118
|
|
119
|
-
it "
|
120
|
-
kgpg(command
|
119
|
+
it "should use the 'command' options" do
|
120
|
+
kgpg(:command => 'other-gpg').send(:pipe).should == '|other-gpg GPG-OPT -e -r foo'
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
124
|
describe 'with password' do
|
125
125
|
def pgpg(extra = {})
|
126
|
-
returning(gpg({gpg
|
127
|
-
stub(g).gpg_password_file(anything) {
|
126
|
+
returning(gpg({:gpg => {:password => 'bar', :options => 'GPG-OPT'}.merge(extra), :options => 'OPT'})) do |g|
|
127
|
+
stub(g).gpg_password_file(anything) {'pass-file'}
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
-
it "
|
131
|
+
it "should use '--passphrase-file' and :options" do
|
132
132
|
pgpg.send(:pipe).should == '|gpg GPG-OPT -c --passphrase-file pass-file'
|
133
133
|
end
|
134
134
|
|
135
|
-
it "
|
136
|
-
pgpg(command
|
135
|
+
it "should use the 'command' options" do
|
136
|
+
pgpg(:command => 'other-gpg').send(:pipe).should == '|other-gpg GPG-OPT -c --passphrase-file pass-file'
|
137
137
|
end
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
141
|
describe :gpg_password_file do
|
142
|
-
it '
|
142
|
+
it 'should create password file' do
|
143
143
|
file = gpg.send(:gpg_password_file, 'foo')
|
144
144
|
expect(File.exist?(file)).to be true
|
145
145
|
File.read(file).should == 'foo'
|
@@ -4,10 +4,10 @@ describe WebTranslateIt::Safe::Gzip do
|
|
4
4
|
|
5
5
|
def def_backup
|
6
6
|
{
|
7
|
-
compressed
|
8
|
-
command
|
9
|
-
extension
|
10
|
-
filename
|
7
|
+
:compressed => false,
|
8
|
+
:command => 'command',
|
9
|
+
:extension => '.foo',
|
10
|
+
:filename => 'qweqwe'
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
@@ -25,17 +25,17 @@ describe WebTranslateIt::Safe::Gzip do
|
|
25
25
|
describe 'when not yet compressed' do
|
26
26
|
before(:each) { @gzip = gzip }
|
27
27
|
|
28
|
-
it '
|
28
|
+
it 'should add .gz extension' do
|
29
29
|
mock(@backup.extension) << '.gz'
|
30
30
|
@gzip.process
|
31
31
|
end
|
32
32
|
|
33
|
-
it '
|
33
|
+
it 'should add |gzip pipe' do
|
34
34
|
mock(@backup.command) << '|gzip'
|
35
35
|
@gzip.process
|
36
36
|
end
|
37
37
|
|
38
|
-
it '
|
38
|
+
it 'should set compressed' do
|
39
39
|
mock(@backup).compressed = true
|
40
40
|
@gzip.process
|
41
41
|
end
|
@@ -43,19 +43,19 @@ describe WebTranslateIt::Safe::Gzip do
|
|
43
43
|
|
44
44
|
describe 'when already compressed' do
|
45
45
|
|
46
|
-
before(:each) { @gzip = gzip({}, extension
|
46
|
+
before(:each) { @gzip = gzip({}, :extension => '.foo', :command => 'foobar', :compressed => true) }
|
47
47
|
|
48
|
-
it '
|
48
|
+
it 'should not touch extension' do
|
49
49
|
@gzip.process
|
50
50
|
@backup.extension.should == '.foo'
|
51
51
|
end
|
52
52
|
|
53
|
-
it '
|
53
|
+
it 'should not touch command' do
|
54
54
|
@gzip.process
|
55
55
|
@backup.command.should == 'foobar'
|
56
56
|
end
|
57
57
|
|
58
|
-
it '
|
58
|
+
it 'should not touch compressed' do
|
59
59
|
@gzip.process
|
60
60
|
@backup.compressed.should == true
|
61
61
|
end
|
@@ -3,24 +3,24 @@ require 'spec_helper'
|
|
3
3
|
describe WebTranslateIt::Safe::Local do
|
4
4
|
def def_config
|
5
5
|
{
|
6
|
-
local
|
7
|
-
path
|
6
|
+
:local => {
|
7
|
+
:path => '/:kind~:id~:timestamp'
|
8
8
|
},
|
9
|
-
keep
|
10
|
-
local
|
9
|
+
:keep => {
|
10
|
+
:local => 2
|
11
11
|
}
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
15
|
def def_backup
|
16
16
|
{
|
17
|
-
kind
|
18
|
-
id
|
19
|
-
timestamp
|
20
|
-
compressed
|
21
|
-
command
|
22
|
-
extension
|
23
|
-
filename
|
17
|
+
:kind => 'mysqldump',
|
18
|
+
:id => 'blog',
|
19
|
+
:timestamp => 'NoW',
|
20
|
+
:compressed => true,
|
21
|
+
:command => 'command',
|
22
|
+
:extension => '.foo.gz',
|
23
|
+
:filename => 'qweqwe'
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
@@ -32,19 +32,19 @@ describe WebTranslateIt::Safe::Local do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe :active? do
|
35
|
-
it '
|
36
|
-
expect(local).to
|
35
|
+
it 'should be true' do
|
36
|
+
expect(local.active?).to be_truthy
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe :path do
|
41
|
-
it '
|
41
|
+
it 'should raise RuntimeError when no path' do
|
42
42
|
lambda {
|
43
43
|
local({}).send :path
|
44
44
|
}.should raise_error(RuntimeError, 'missing :local/:path')
|
45
45
|
end
|
46
46
|
|
47
|
-
it '
|
47
|
+
it 'should use local/path' do
|
48
48
|
local.send(:path).should == '/mysqldump~blog~NoW'
|
49
49
|
end
|
50
50
|
end
|
@@ -53,21 +53,21 @@ describe WebTranslateIt::Safe::Local do
|
|
53
53
|
before(:each) do
|
54
54
|
@local = local
|
55
55
|
stub(@local).system
|
56
|
-
stub(@local).full_path {
|
56
|
+
stub(@local).full_path {'file-path'}
|
57
57
|
stub(FileUtils).mkdir_p
|
58
58
|
end
|
59
59
|
|
60
|
-
it '
|
60
|
+
it 'should call system to save the file' do
|
61
61
|
mock(@local).system('command>file-path')
|
62
62
|
@local.send(:save)
|
63
63
|
end
|
64
64
|
|
65
|
-
it '
|
65
|
+
it 'should create directory' do
|
66
66
|
mock(FileUtils).mkdir_p('/mysqldump~blog~NoW')
|
67
67
|
@local.send(:save)
|
68
68
|
end
|
69
69
|
|
70
|
-
it '
|
70
|
+
it 'should set backup.path' do
|
71
71
|
mock(@backup).path = 'file-path'
|
72
72
|
@local.send(:save)
|
73
73
|
end
|
@@ -77,7 +77,7 @@ describe WebTranslateIt::Safe::Local do
|
|
77
77
|
|
78
78
|
it 'should not create directory'
|
79
79
|
it 'should not call system'
|
80
|
-
it '
|
80
|
+
it 'should set backup.path' do
|
81
81
|
mock(@backup).path = 'file-path'
|
82
82
|
@local.send(:save)
|
83
83
|
end
|
@@ -86,21 +86,21 @@ describe WebTranslateIt::Safe::Local do
|
|
86
86
|
|
87
87
|
describe :cleanup do
|
88
88
|
before(:each) do
|
89
|
-
@files = [4,
|
90
|
-
stub(File).file?(anything) {
|
91
|
-
stub(File).size(anything) {
|
89
|
+
@files = [4,1,3,2].map { |i| "/mysqldump~blog~NoW/qweqwe.#{i}" }
|
90
|
+
stub(File).file?(anything) {true}
|
91
|
+
stub(File).size(anything) {1}
|
92
92
|
stub(File).unlink
|
93
93
|
end
|
94
94
|
|
95
|
-
it '
|
96
|
-
@local = local(def_config.merge(keep
|
95
|
+
it 'should check [:keep, :local]' do
|
96
|
+
@local = local(def_config.merge(:keep => {}))
|
97
97
|
dont_allow(Dir).[]
|
98
98
|
@local.send :cleanup
|
99
99
|
end
|
100
100
|
|
101
|
-
it '
|
101
|
+
it 'should delete extra files' do
|
102
102
|
@local = local
|
103
|
-
mock(Dir).[]('/mysqldump~blog~NoW/qweqwe.*') {
|
103
|
+
mock(Dir).[]('/mysqldump~blog~NoW/qweqwe.*') {@files}
|
104
104
|
mock(File).unlink('/mysqldump~blog~NoW/qweqwe.1')
|
105
105
|
mock(File).unlink('/mysqldump~blog~NoW/qweqwe.2')
|
106
106
|
@local.send :cleanup
|
@@ -3,50 +3,50 @@ require 'spec_helper'
|
|
3
3
|
describe WebTranslateIt::Safe::Mongodump do
|
4
4
|
def def_config
|
5
5
|
{
|
6
|
-
host
|
7
|
-
user
|
8
|
-
password
|
6
|
+
:host => 'prod.example.com',
|
7
|
+
:user => 'testuser',
|
8
|
+
:password => 'p4ssw0rd',
|
9
9
|
}
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def mongodump(id = :foo, config = def_config)
|
13
13
|
WebTranslateIt::Safe::Mongodump.new(id, WebTranslateIt::Safe::Config::Node.new(nil, config))
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
before(:each) do
|
17
|
-
stub(Time).now.stub!.strftime {
|
17
|
+
stub(Time).now.stub!.strftime {'NOW'}
|
18
18
|
@output_folder = File.join(WebTranslateIt::Safe::TmpFile.tmproot, 'mongodump')
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
after(:each) { WebTranslateIt::Safe::TmpFile.cleanup }
|
22
|
-
|
22
|
+
|
23
23
|
describe :backup do
|
24
24
|
before(:each) do
|
25
25
|
@mongo = mongodump
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
{
|
29
|
-
id
|
30
|
-
kind
|
31
|
-
extension
|
32
|
-
filename
|
29
|
+
:id => 'foo',
|
30
|
+
:kind => 'mongodump',
|
31
|
+
:extension => '.tar',
|
32
|
+
:filename => 'mongodump-foo.NOW'
|
33
33
|
}.each do |k, v|
|
34
|
-
it "
|
34
|
+
it "should set #{k} to #{v}" do
|
35
35
|
@mongo.backup.send(k).should == v
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
|
-
it '
|
38
|
+
|
39
|
+
it 'should set the command' do
|
40
40
|
@mongo.backup.send(:command).should == "mongodump -q \"{xxxx : { \\$ne : 0 } }\" --db foo --host prod.example.com -u testuser -p p4ssw0rd --out #{@output_folder} && cd #{@output_folder} && tar cf - ."
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
{
|
44
|
-
host
|
45
|
-
user
|
46
|
-
password
|
47
|
-
}.each do |key, v|
|
48
|
-
it "
|
49
|
-
@mongo = mongodump(:foo, def_config.reject! {
|
44
|
+
:host => '--host ',
|
45
|
+
:user => '-u ',
|
46
|
+
:password => '-p '
|
47
|
+
}.each do |key, v|
|
48
|
+
it "should not add #{key} to command if it is not present" do
|
49
|
+
@mongo = mongodump(:foo, def_config.reject! {|k,v| k == key})
|
50
50
|
@mongo.backup.send(:command).should_not =~ /#{v}/
|
51
51
|
end
|
52
52
|
end
|
@@ -4,13 +4,13 @@ describe WebTranslateIt::Safe::Mysqldump do
|
|
4
4
|
|
5
5
|
def def_config(extra = {})
|
6
6
|
{
|
7
|
-
options
|
8
|
-
user
|
9
|
-
password
|
10
|
-
host
|
11
|
-
port
|
12
|
-
socket
|
13
|
-
skip_tables
|
7
|
+
:options => 'OPTS',
|
8
|
+
:user => 'User',
|
9
|
+
:password => 'pwd',
|
10
|
+
:host => 'localhost',
|
11
|
+
:port => 7777,
|
12
|
+
:socket => 'socket',
|
13
|
+
:skip_tables => [:bar, :baz]
|
14
14
|
}.merge(extra)
|
15
15
|
end
|
16
16
|
|
@@ -19,7 +19,7 @@ describe WebTranslateIt::Safe::Mysqldump do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
before(:each) do
|
22
|
-
stub(Time).now.stub!.strftime {
|
22
|
+
stub(Time).now.stub!.strftime {'NOW'}
|
23
23
|
end
|
24
24
|
|
25
25
|
after(:each) { WebTranslateIt::Safe::TmpFile.cleanup }
|
@@ -27,17 +27,17 @@ describe WebTranslateIt::Safe::Mysqldump do
|
|
27
27
|
describe :backup do
|
28
28
|
before(:each) do
|
29
29
|
@mysql = mysqldump
|
30
|
-
stub(@mysql).mysql_password_file {
|
30
|
+
stub(@mysql).mysql_password_file {'/tmp/pwd'}
|
31
31
|
end
|
32
32
|
|
33
33
|
{
|
34
|
-
id
|
35
|
-
kind
|
36
|
-
extension
|
37
|
-
filename
|
38
|
-
command
|
34
|
+
:id => 'foo',
|
35
|
+
:kind => 'mysqldump',
|
36
|
+
:extension => '.sql',
|
37
|
+
:filename => 'mysqldump-foo.NOW',
|
38
|
+
:command => 'mysqldump --defaults-extra-file=/tmp/pwd OPTS --ignore-table=foo.bar --ignore-table=foo.baz foo',
|
39
39
|
}.each do |k, v|
|
40
|
-
it "
|
40
|
+
it "should set #{k} to #{v}" do
|
41
41
|
@mysql.backup.send(k).should == v
|
42
42
|
end
|
43
43
|
end
|
@@ -45,38 +45,38 @@ describe WebTranslateIt::Safe::Mysqldump do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
describe :mysql_skip_tables do
|
48
|
-
it '
|
48
|
+
it 'should return nil if no skip_tables' do
|
49
49
|
config = def_config.dup
|
50
50
|
config.delete(:skip_tables)
|
51
51
|
m = mysqldump(:foo, WebTranslateIt::Safe::Config::Node.new(nil, config))
|
52
|
-
stub(m).timestamp {
|
52
|
+
stub(m).timestamp {'NOW'}
|
53
53
|
m.send(:mysql_skip_tables).should be_nil
|
54
54
|
m.backup.command.should_not match(/ignore-table/)
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "should return '' if skip_tables empty" do
|
58
58
|
config = def_config.dup
|
59
59
|
config[:skip_tables] = []
|
60
60
|
m = mysqldump(:foo, WebTranslateIt::Safe::Config::Node.new(nil, config))
|
61
|
-
stub(m).timestamp {
|
62
|
-
m.send(:mysql_skip_tables).should
|
61
|
+
stub(m).timestamp {'NOW'}
|
62
|
+
m.send(:mysql_skip_tables).should == ''
|
63
63
|
m.backup.command.should_not match(/ignore-table/)
|
64
64
|
end
|
65
65
|
|
66
66
|
end
|
67
67
|
|
68
68
|
describe :mysql_password_file do
|
69
|
-
it '
|
70
|
-
m = mysqldump(:foo, def_config(password
|
69
|
+
it 'should create passwords file with quoted values' do
|
70
|
+
m = mysqldump(:foo, def_config(:password => '#qwe"asd\'zxc'))
|
71
71
|
file = m.send(:mysql_password_file)
|
72
|
-
File.exist?(file).should
|
73
|
-
File.read(file).should ==
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
File.exist?(file).should == true
|
73
|
+
File.read(file).should == <<-PWD
|
74
|
+
[mysqldump]
|
75
|
+
user = "User"
|
76
|
+
password = "#qwe\\"asd'zxc"
|
77
|
+
socket = "socket"
|
78
|
+
host = "localhost"
|
79
|
+
port = 7777
|
80
80
|
PWD
|
81
81
|
end
|
82
82
|
end
|
@@ -4,12 +4,12 @@ describe WebTranslateIt::Safe::Pgdump do
|
|
4
4
|
|
5
5
|
def def_config
|
6
6
|
{
|
7
|
-
options
|
8
|
-
user
|
9
|
-
password
|
10
|
-
host
|
11
|
-
port
|
12
|
-
skip_tables
|
7
|
+
:options => 'OPTS',
|
8
|
+
:user => 'User',
|
9
|
+
:password => 'pwd',
|
10
|
+
:host => 'localhost',
|
11
|
+
:port => 7777,
|
12
|
+
:skip_tables => [:bar, :baz]
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
@@ -18,7 +18,7 @@ describe WebTranslateIt::Safe::Pgdump do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
before(:each) do
|
21
|
-
stub(Time).now.stub!.strftime {
|
21
|
+
stub(Time).now.stub!.strftime {'NOW'}
|
22
22
|
end
|
23
23
|
|
24
24
|
after(:each) { WebTranslateIt::Safe::TmpFile.cleanup }
|
@@ -29,13 +29,13 @@ describe WebTranslateIt::Safe::Pgdump do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
{
|
32
|
-
id
|
33
|
-
kind
|
34
|
-
extension
|
35
|
-
filename
|
36
|
-
command
|
32
|
+
:id => 'foo',
|
33
|
+
:kind => 'pgdump',
|
34
|
+
:extension => '.sql',
|
35
|
+
:filename => 'pgdump-foo.NOW',
|
36
|
+
:command => "pg_dump OPTS --username='User' --host='localhost' --port='7777' foo",
|
37
37
|
}.each do |k, v|
|
38
|
-
it "
|
38
|
+
it "should set #{k} to #{v}" do
|
39
39
|
@pg.backup.send(k).should == v
|
40
40
|
end
|
41
41
|
end
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe WebTranslateIt::Safe::Svndump do
|
4
4
|
def def_config
|
5
5
|
{
|
6
|
-
options
|
7
|
-
repo_path
|
6
|
+
:options => 'OPTS',
|
7
|
+
:repo_path => 'bar/baz'
|
8
8
|
}
|
9
9
|
end
|
10
10
|
|
@@ -13,7 +13,7 @@ describe WebTranslateIt::Safe::Svndump do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
before(:each) do
|
16
|
-
stub(Time).now.stub!.strftime {
|
16
|
+
stub(Time).now.stub!.strftime {'NOW'}
|
17
17
|
end
|
18
18
|
|
19
19
|
after(:each) { WebTranslateIt::Safe::TmpFile.cleanup }
|
@@ -24,13 +24,13 @@ describe WebTranslateIt::Safe::Svndump do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
{
|
27
|
-
id
|
28
|
-
kind
|
29
|
-
extension
|
30
|
-
filename
|
31
|
-
command
|
27
|
+
:id => 'foo',
|
28
|
+
:kind => 'svndump',
|
29
|
+
:extension => '.svn',
|
30
|
+
:filename => 'svndump-foo.NOW',
|
31
|
+
:command => 'svnadmin dump OPTS bar/baz',
|
32
32
|
}.each do |k, v|
|
33
|
-
it "
|
33
|
+
it "should set #{k} to #{v}" do
|
34
34
|
@svn.backup.send(k).should == v
|
35
35
|
end
|
36
36
|
end
|
data/webtranslateit-safe.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'English'
|
2
1
|
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'webtranslateit/safe/version'
|
@@ -9,18 +8,18 @@ Gem::Specification.new do |spec|
|
|
9
8
|
spec.authors = ['Edouard Briere', 'Vitaly Kushner']
|
10
9
|
spec.email = ['support@webtranslateit.com']
|
11
10
|
spec.required_ruby_version = '>= 3.2'
|
12
|
-
spec.description =
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
spec.description = <<-DESC
|
12
|
+
WebTranslateIt-Safe is a simple tool to backup databases (MySQL and PostgreSQL), Subversion repositories (with svndump) and just files.
|
13
|
+
Backups can be stored locally or remotely and can be enctypted.
|
14
|
+
Remote storage is supported on Amazon S3, Rackspace Cloud Files, or just plain FTP/SFTP.
|
16
15
|
DESC
|
17
16
|
spec.summary = 'Backup filesystem and databases (MySQL and PostgreSQL) locally or to a remote server/service (with encryption)'
|
18
|
-
spec.homepage = '
|
17
|
+
spec.homepage = 'http://github.com/webtranslateit/safe'
|
19
18
|
spec.license = 'MIT'
|
20
19
|
|
21
20
|
spec.default_executable = 'webtranslateit-safe'
|
22
21
|
|
23
|
-
spec.files = `git ls-files`.split(
|
22
|
+
spec.files = `git ls-files`.split($/)
|
24
23
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
25
24
|
spec.require_paths = ['lib']
|
26
25
|
|