sweety_backy 0.0.21 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +20 -13
- data/lib/sweety_backy/commander.rb +11 -5
- data/lib/sweety_backy/runner.rb +2 -1
- data/lib/sweety_backy/utils.rb +13 -15
- data/lib/sweety_backy/version.rb +1 -1
- data/sweety_backy.gemspec +1 -0
- data/test/commander_test.rb +52 -9
- data/test/opts_reader_test.rb +8 -8
- data/test/runner_test.rb +3 -4
- data/test/s3/commander_s3_test.rb +12 -12
- data/test/s3/runner_s3_test.rb +29 -29
- data/test/s3/s3_test.rb +2 -2
- data/test/test_helper.rb +4 -2
- data/test/utils_test.rb +11 -11
- metadata +93 -103
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ff6fbce5aad9facf8bd4c57136c83f760b705a3
|
4
|
+
data.tar.gz: 726c083cb0a1aa49327e1d7ad5d7bc8c015047d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: efa3fad6fe9549c1bc579a935e37d87d5b8dea55eaba575d9a37c0eac3b5e162644f6543123558982b74d4c3378e881e23e912032b51ac43c5defb531c0d39ef
|
7
|
+
data.tar.gz: 12a1e8006d0409002259cca2b173b7683d0512770a5a41b3bf18e04aa9ffe4cc5f7652e96d8336a6cf464c4f45b2de9face7e74832419cd0e45af47279738369
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sweety_backy (0.0.
|
5
|
-
aws-sdk
|
4
|
+
sweety_backy (0.0.25)
|
5
|
+
aws-sdk (= 1.7.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
@@ -12,19 +12,22 @@ GEM
|
|
12
12
|
json (~> 1.4)
|
13
13
|
nokogiri (>= 1.4.4)
|
14
14
|
uuidtools (~> 2.1)
|
15
|
-
chronic (0.
|
16
|
-
delorean (
|
15
|
+
chronic (0.10.2)
|
16
|
+
delorean (2.1.0)
|
17
17
|
chronic
|
18
|
-
httparty (0.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
httparty (0.16.2)
|
19
|
+
multi_xml (>= 0.5.2)
|
20
|
+
json (1.8.6)
|
21
|
+
metaclass (0.0.4)
|
22
|
+
mini_portile2 (2.3.0)
|
23
|
+
minitest (5.11.3)
|
24
|
+
mocha (1.5.0)
|
25
|
+
metaclass (~> 0.0.1)
|
26
|
+
multi_xml (0.6.0)
|
27
|
+
nokogiri (1.8.3)
|
28
|
+
mini_portile2 (~> 2.3.0)
|
26
29
|
rake (0.9.2)
|
27
|
-
uuidtools (2.1.
|
30
|
+
uuidtools (2.1.5)
|
28
31
|
|
29
32
|
PLATFORMS
|
30
33
|
ruby
|
@@ -32,6 +35,10 @@ PLATFORMS
|
|
32
35
|
DEPENDENCIES
|
33
36
|
bundler (>= 1.0.0.rc.6)
|
34
37
|
delorean
|
38
|
+
minitest
|
35
39
|
mocha
|
36
40
|
rake
|
37
41
|
sweety_backy!
|
42
|
+
|
43
|
+
BUNDLED WITH
|
44
|
+
1.15.4
|
@@ -11,14 +11,20 @@ module SweetyBacky
|
|
11
11
|
SweetyBacky::Utils.log "doing database backup #{database_name} on #{backup_path}"
|
12
12
|
|
13
13
|
FileUtils.mkdir_p( File.dirname( backup_path ) )
|
14
|
-
|
14
|
+
_tmp_sql_file_path = tmp_sql_file_path(backup_path)
|
15
15
|
|
16
16
|
database_pass = opts[:database_pass].empty? ? '' : "-p'#{opts[:database_pass]}'"
|
17
|
+
database_host = opts[:database_host].nil? ? '' : "-h#{opts[:database_host]}"
|
18
|
+
database_port = opts[:database_port].nil? ? '' : "-P#{opts[:database_port]}"
|
17
19
|
|
18
|
-
SweetyBacky::Utils::command( "mysqldump -u#{opts[:database_user]} #{database_pass} #{database_name} > #{
|
19
|
-
SweetyBacky::Utils::command( "tar -cz --same-permissions --file #{backup_path} --directory #{File.dirname(
|
20
|
+
SweetyBacky::Utils::command( "mysqldump #{database_host} #{database_port} -u#{opts[:database_user]} #{database_pass} #{database_name} > #{_tmp_sql_file_path}" )
|
21
|
+
SweetyBacky::Utils::command( "tar -cz --same-permissions --file #{backup_path} --directory #{File.dirname(_tmp_sql_file_path)} #{File.basename(_tmp_sql_file_path)}" )
|
20
22
|
|
21
|
-
File.delete(
|
23
|
+
File.delete( _tmp_sql_file_path )
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.tmp_sql_file_path(backup_path)
|
27
|
+
File.join( Dir::tmpdir, "#{File.basename( backup_path, '.tar.gz' )}" )
|
22
28
|
end
|
23
29
|
|
24
30
|
def self.clean( opts )
|
@@ -118,4 +124,4 @@ module SweetyBacky
|
|
118
124
|
File.delete( file_path )
|
119
125
|
end
|
120
126
|
end
|
121
|
-
end
|
127
|
+
end
|
data/lib/sweety_backy/runner.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'tmpdir'
|
4
4
|
require 'yaml'
|
5
|
+
require 'date'
|
5
6
|
require File.dirname(__FILE__) + "/utils.rb"
|
6
7
|
|
7
8
|
module SweetyBacky
|
@@ -144,7 +145,7 @@ module SweetyBacky
|
|
144
145
|
def upload_files_backup_to_s3( backup_path, md5_path )
|
145
146
|
backup_paths = opts[:slices_size] ? Dir.glob( "#{backup_path}.part_*" ) : [backup_path]
|
146
147
|
|
147
|
-
backup_paths.each do |backup_path|
|
148
|
+
backup_paths.sort.each do |backup_path|
|
148
149
|
SweetyBacky::S3.upload(
|
149
150
|
backup_path,
|
150
151
|
"#{@opts[:target_path]}/files/#{File.basename( backup_path )}",
|
data/lib/sweety_backy/utils.rb
CHANGED
@@ -1,42 +1,40 @@
|
|
1
1
|
module SweetyBacky
|
2
2
|
class Utils
|
3
|
-
|
3
|
+
|
4
4
|
def self.period
|
5
5
|
return 'yearly' if( is_last_day_of_year? )
|
6
6
|
return 'monthly' if( is_last_day_of_month? )
|
7
7
|
return 'weekly' if( is_last_day_of_week? )
|
8
8
|
return 'daily'
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def self.is_last_day_of_year?
|
12
12
|
return Date.new(Date.today.year, 12, -1) == Date.today
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def self.is_last_day_of_month?
|
16
16
|
return Date.new(Date.today.year, Date.today.month, -1) == Date.today
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def self.is_last_day_of_week?
|
20
20
|
return Date.today.cwday == 7
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def self.command( _command )
|
24
24
|
Utils.log "command: #{_command}"
|
25
|
-
|
26
|
-
result =
|
27
|
-
|
28
|
-
raise "ERROR: on command: '#{_command}', result: '#{result}'"
|
29
|
-
|
30
|
-
return result
|
25
|
+
|
26
|
+
result = system(_command)
|
27
|
+
|
28
|
+
raise "ERROR: on command: '#{_command}', result: '#{result}'" if !result
|
31
29
|
end
|
32
|
-
|
30
|
+
|
33
31
|
def self.log( msg )
|
34
32
|
puts "#{Time.now.strftime("%Y-%m-%d %H:%M")}: #{msg}"
|
35
33
|
end
|
36
|
-
|
34
|
+
|
37
35
|
def self.namerize( path )
|
38
36
|
path.gsub('/', '.').gsub(/^\./, '')
|
39
37
|
end
|
40
|
-
|
38
|
+
|
41
39
|
end
|
42
|
-
end
|
40
|
+
end
|
data/lib/sweety_backy/version.rb
CHANGED
data/sweety_backy.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.rubyforge_project = "SweetyBacky"
|
15
15
|
|
16
16
|
s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
|
17
|
+
s.add_development_dependency "minitest"
|
17
18
|
s.add_development_dependency "mocha"
|
18
19
|
s.add_development_dependency "delorean"
|
19
20
|
s.add_development_dependency "rake"
|
data/test/commander_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
|
-
class CommanderTest < Test
|
3
|
+
class CommanderTest < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
6
|
SweetyBacky::Utils.stubs(:log)
|
@@ -43,6 +43,49 @@ class CommanderTest < Test::Unit::TestCase
|
|
43
43
|
assert_match( /\sback.sql$/, result )
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_do_databases_backup_mysql_parameters
|
47
|
+
SweetyBacky::Utils.stubs(:command)
|
48
|
+
SweetyBacky::Commander.expects(:tmp_sql_file_path).returns("TMP_SQL_FILE_PATH").at_least_once
|
49
|
+
FileUtils.expects(:mkdir_p).at_least_once
|
50
|
+
File.expects(:delete).at_least_once
|
51
|
+
|
52
|
+
# Basic params
|
53
|
+
SweetyBacky::Utils.expects(:command).with("mysqldump -utest test > TMP_SQL_FILE_PATH")
|
54
|
+
SweetyBacky::Commander.do_database_backup(
|
55
|
+
"test",
|
56
|
+
"#{@tmp_dir}/back.sql.tar.gz",
|
57
|
+
{
|
58
|
+
:database_user => "test",
|
59
|
+
:database_pass => ""
|
60
|
+
}
|
61
|
+
)
|
62
|
+
|
63
|
+
# With host
|
64
|
+
SweetyBacky::Utils.expects(:command).with("mysqldump -hHOST -utest test > TMP_SQL_FILE_PATH")
|
65
|
+
SweetyBacky::Commander.do_database_backup(
|
66
|
+
"test",
|
67
|
+
"#{@tmp_dir}/back.sql.tar.gz",
|
68
|
+
{
|
69
|
+
:database_user => "test",
|
70
|
+
:database_pass => "",
|
71
|
+
:database_host => "HOST"
|
72
|
+
}
|
73
|
+
)
|
74
|
+
|
75
|
+
# With host and port
|
76
|
+
SweetyBacky::Utils.expects(:command).with("mysqldump -hHOST -PPORT -utest test > TMP_SQL_FILE_PATH")
|
77
|
+
SweetyBacky::Commander.do_database_backup(
|
78
|
+
"test",
|
79
|
+
"#{@tmp_dir}/back.sql.tar.gz",
|
80
|
+
{
|
81
|
+
:database_user => "test",
|
82
|
+
:database_pass => "",
|
83
|
+
:database_host => "HOST",
|
84
|
+
:database_port => "PORT"
|
85
|
+
}
|
86
|
+
)
|
87
|
+
|
88
|
+
end
|
46
89
|
|
47
90
|
def test_clean
|
48
91
|
opts = {
|
@@ -126,9 +169,9 @@ class CommanderTest < Test::Unit::TestCase
|
|
126
169
|
'name1.20100704.weekly',
|
127
170
|
'name2.20100721.daily'
|
128
171
|
].each do |file_part|
|
129
|
-
|
130
|
-
|
131
|
-
|
172
|
+
refute_match( /#{file_part}.tar.gz/, files_keeped )
|
173
|
+
refute_match( /#{file_part}.tar.gz.md5/, files_keeped )
|
174
|
+
refute_match( /#{file_part}.sql.tar.gz/, databases_keeped )
|
132
175
|
end
|
133
176
|
end
|
134
177
|
|
@@ -217,10 +260,10 @@ class CommanderTest < Test::Unit::TestCase
|
|
217
260
|
'name1.20100704.weekly',
|
218
261
|
'name2.20100721.daily'
|
219
262
|
].each do |file_part|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
263
|
+
refute_match( /#{file_part}.tar.gz.part_aa/, files_keeped )
|
264
|
+
refute_match( /#{file_part}.tar.gz.part_ab/, files_keeped )
|
265
|
+
refute_match( /#{file_part}.tar.gz.md5/, files_keeped )
|
266
|
+
refute_match( /#{file_part}.sql.tar.gz/, databases_keeped )
|
224
267
|
end
|
225
268
|
end
|
226
269
|
|
data/test/opts_reader_test.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
|
-
class OptsReaderTest < Test
|
3
|
+
class OptsReaderTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
SweetyBacky::Utils.stubs(:log)
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def test_read_opts
|
9
9
|
opts = SweetyBacky::OptsReader.read_opts( "#{FIXTURES_PATH}/config_s3.yml" )
|
10
|
-
|
10
|
+
|
11
11
|
assert_equal( [ "path1", "path2" ], opts[:paths] )
|
12
12
|
assert_equal( [ "db1", "db2" ], opts[:databases] )
|
13
13
|
assert_equal( 1, opts[:yearly] )
|
@@ -16,10 +16,10 @@ class OptsReaderTest < Test::Unit::TestCase
|
|
16
16
|
assert_equal( 4, opts[:daily] )
|
17
17
|
assert_equal( 'database_user', opts[:database_user] )
|
18
18
|
assert_equal( 'database_pass', opts[:database_pass] )
|
19
|
-
assert_equal( 'bucket_name', opts[:s3_opts][:bucket] )
|
19
|
+
assert_equal( 'bucket_name', opts[:s3_opts][:bucket] )
|
20
20
|
assert_equal( 's3/path/path', opts[:s3_opts][:path] )
|
21
21
|
assert_equal( '/path/.s3.passwd', opts[:s3_opts][:passwd_file] )
|
22
22
|
end
|
23
|
-
|
24
|
-
|
25
|
-
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
data/test/runner_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
|
-
class RunnerTest < Test
|
3
|
+
class RunnerTest < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
6
|
SweetyBacky::Utils.stubs(:log)
|
@@ -27,6 +27,7 @@ class RunnerTest < Test::Unit::TestCase
|
|
27
27
|
|
28
28
|
@runner = SweetyBacky::Runner.new
|
29
29
|
@runner.config( @opts )
|
30
|
+
|
30
31
|
end
|
31
32
|
|
32
33
|
def teardown
|
@@ -139,8 +140,6 @@ class RunnerTest < Test::Unit::TestCase
|
|
139
140
|
"#{FIXTURES_PATH}/slices/file1.txt.md5"
|
140
141
|
)
|
141
142
|
|
142
|
-
|
143
|
-
|
144
143
|
# FileUtils.expects(:rm).with()
|
145
144
|
end
|
146
145
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/../test_helper"
|
2
2
|
|
3
|
-
class CommanderS3Test < Test
|
4
|
-
|
3
|
+
class CommanderS3Test < Minitest::Test
|
4
|
+
|
5
5
|
def setup
|
6
6
|
SweetyBacky::Utils.stubs(:log)
|
7
7
|
|
@@ -21,9 +21,9 @@ class CommanderS3Test < Test::Unit::TestCase
|
|
21
21
|
:working_path => @tmp_dir,
|
22
22
|
:target_path => 'test/path'
|
23
23
|
}
|
24
|
-
|
24
|
+
|
25
25
|
s3 = AWS::S3.new( SweetyBacky::S3.read_s3_password( @opts[:s3_opts][:passwd_file] ) )
|
26
|
-
|
26
|
+
|
27
27
|
@bucket = s3.buckets.create( @opts[:s3_opts][:bucket] )
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ class CommanderS3Test < Test::Unit::TestCase
|
|
31
31
|
@bucket.delete!
|
32
32
|
end
|
33
33
|
|
34
|
-
def test_clean
|
34
|
+
def test_clean
|
35
35
|
[
|
36
36
|
'name1.20081231.yearly',
|
37
37
|
'name1.20081232.yearly',
|
@@ -56,12 +56,12 @@ class CommanderS3Test < Test::Unit::TestCase
|
|
56
56
|
SweetyBacky::S3.upload( "#{FIXTURES_PATH}/file.txt", "#{@opts[:s3_opts][:path]}/files/#{file_part}.tar.gz", @opts[:s3_opts] )
|
57
57
|
SweetyBacky::S3.upload( "#{FIXTURES_PATH}/file.txt", "#{@opts[:s3_opts][:path]}/databases/#{file_part}.sql.tar.gz", @opts[:s3_opts] )
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
SweetyBacky::Commander.clean( @opts )
|
61
|
-
|
61
|
+
|
62
62
|
files_keeped = SweetyBacky::S3.paths_in( "#{@opts[:s3_opts][:path]}/files/*", @opts[:s3_opts] ).join( "\n" )
|
63
63
|
databases_keeped = SweetyBacky::S3.paths_in( "#{@opts[:s3_opts][:path]}/databases/*", @opts[:s3_opts] ).join( "\n" )
|
64
|
-
|
64
|
+
|
65
65
|
# files to keep
|
66
66
|
[
|
67
67
|
'name1.20081232.yearly',
|
@@ -81,7 +81,7 @@ class CommanderS3Test < Test::Unit::TestCase
|
|
81
81
|
assert_match( "#{file_part}.tar.gz", files_keeped )
|
82
82
|
assert_match( "#{file_part}.sql.tar.gz", databases_keeped )
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
# files to deleted
|
86
86
|
[
|
87
87
|
'name1.20081231.yearly',
|
@@ -90,11 +90,11 @@ class CommanderS3Test < Test::Unit::TestCase
|
|
90
90
|
'name1.20100704.weekly',
|
91
91
|
'name2.20100721.daily'
|
92
92
|
].each do |file_part|
|
93
|
-
|
94
|
-
|
93
|
+
refute_match( /#{file_part}.tar.gz/, files_keeped )
|
94
|
+
refute_match( /#{file_part}.sql.tar.gz/, databases_keeped )
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
|
99
99
|
end
|
100
100
|
|
data/test/s3/runner_s3_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/../test_helper"
|
2
2
|
|
3
|
-
class RunnerS3Test < Test
|
4
|
-
|
3
|
+
class RunnerS3Test < Minitest::Test
|
4
|
+
|
5
5
|
def setup
|
6
6
|
SweetyBacky::Utils.stubs(:log)
|
7
|
-
|
7
|
+
|
8
8
|
# runner
|
9
9
|
@opts = {
|
10
10
|
:paths => [ "#{FIXTURES_PATH}/path" ],
|
@@ -22,10 +22,10 @@ class RunnerS3Test < Test::Unit::TestCase
|
|
22
22
|
:path => 'test/path'
|
23
23
|
}
|
24
24
|
}
|
25
|
-
|
25
|
+
|
26
26
|
@runner = SweetyBacky::Runner.new
|
27
27
|
@runner.config( @opts )
|
28
|
-
|
28
|
+
|
29
29
|
s3 = AWS::S3.new( SweetyBacky::S3.read_s3_password( @opts[:s3_opts][:passwd_file] ) )
|
30
30
|
@bucket = s3.buckets.create( @opts[:s3_opts][:bucket] )
|
31
31
|
end
|
@@ -33,44 +33,44 @@ class RunnerS3Test < Test::Unit::TestCase
|
|
33
33
|
def teardown
|
34
34
|
@bucket.delete!
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def test_do_backup_daily
|
38
38
|
SweetyBacky::Utils.stubs( :period ).returns( 'daily' )
|
39
|
-
|
39
|
+
|
40
40
|
@runner.do_backup
|
41
|
-
|
42
|
-
assert(
|
41
|
+
|
42
|
+
assert(
|
43
43
|
@bucket.
|
44
|
-
objects[
|
44
|
+
objects[
|
45
45
|
"test/path/files/#{SweetyBacky::Utils.namerize( @opts[:paths][0] )}.#{Date.today.strftime('%Y%m%d')}.daily.tar.gz"
|
46
|
-
].exists?
|
46
|
+
].exists?
|
47
47
|
)
|
48
|
-
|
49
|
-
assert(
|
48
|
+
|
49
|
+
assert(
|
50
50
|
@bucket.
|
51
|
-
objects[
|
51
|
+
objects[
|
52
52
|
"test/path/databases/test.#{Date.today.strftime('%Y%m%d')}.daily.sql.tar.gz"
|
53
|
-
].exists?
|
53
|
+
].exists?
|
54
54
|
)
|
55
|
-
|
56
|
-
assert(
|
55
|
+
|
56
|
+
assert(
|
57
57
|
@bucket.
|
58
|
-
objects[
|
58
|
+
objects[
|
59
59
|
"test/path/files/#{SweetyBacky::Utils.namerize( @opts[:paths][0] )}.#{Date.today.strftime('%Y%m%d')}.daily.tar.gz.md5"
|
60
|
-
].exists?
|
60
|
+
].exists?
|
61
61
|
)
|
62
|
-
|
63
|
-
assert(
|
62
|
+
|
63
|
+
assert(
|
64
64
|
@bucket.
|
65
|
-
objects[
|
65
|
+
objects[
|
66
66
|
"test/path/databases/test.#{Date.today.strftime('%Y%m%d')}.daily.sql.tar.gz.md5"
|
67
|
-
].exists?
|
67
|
+
].exists?
|
68
68
|
)
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def test_initialize_with_config_file
|
72
|
-
SweetyBacky::OptsReader.expects( :read_opts ).with( '/path/config.yml' ).returns(
|
73
|
-
{
|
72
|
+
SweetyBacky::OptsReader.expects( :read_opts ).with( '/path/config.yml' ).returns(
|
73
|
+
{
|
74
74
|
:paths => [ 'pepe', 'juan' ],
|
75
75
|
:storage_system => :s3,
|
76
76
|
:s3_opts => {
|
@@ -78,9 +78,9 @@ class RunnerS3Test < Test::Unit::TestCase
|
|
78
78
|
}
|
79
79
|
}
|
80
80
|
)
|
81
|
-
|
81
|
+
|
82
82
|
runner = SweetyBacky::Runner.new( "/path/config.yml" )
|
83
|
-
|
83
|
+
|
84
84
|
assert_equal( [ "pepe", "juan" ], runner.opts[:paths] )
|
85
85
|
assert_equal( [], runner.opts[:databases] )
|
86
86
|
assert_equal( 1, runner.opts[:yearly] )
|
@@ -91,6 +91,6 @@ class RunnerS3Test < Test::Unit::TestCase
|
|
91
91
|
assert_equal( '/s3/path', runner.opts[:s3_opts][:path] )
|
92
92
|
assert_equal( '/s3/path', runner.opts[:target_path] )
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
end
|
96
96
|
|
data/test/s3/s3_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/../test_helper"
|
2
2
|
|
3
3
|
|
4
|
-
class S3Test < Test
|
4
|
+
class S3Test < Minitest::Test
|
5
5
|
def setup
|
6
6
|
SweetyBacky::Utils.stubs(:log)
|
7
7
|
|
@@ -63,4 +63,4 @@ class S3Test < Test::Unit::TestCase
|
|
63
63
|
assert_equal( false, SweetyBacky::S3.exists?( "test/path/file2.txt", @opts ) )
|
64
64
|
end
|
65
65
|
|
66
|
-
end
|
66
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/../lib/sweety_backy"
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require '
|
4
|
+
require 'fileutils'
|
5
5
|
require 'mocha'
|
6
6
|
require 'delorean'
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'mocha/minitest'
|
7
9
|
|
8
10
|
|
9
|
-
FIXTURES_PATH = File.expand_path "#{File.dirname(__FILE__)}/fixtures"
|
11
|
+
FIXTURES_PATH = File.expand_path "#{File.dirname(__FILE__)}/fixtures"
|
data/test/utils_test.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
|
-
class UtilsTest < Test
|
3
|
+
class UtilsTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
SweetyBacky::Utils.stubs(:log)
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def test_error_on_command
|
9
|
-
|
9
|
+
assert_raises RuntimeError do
|
10
10
|
SweetyBacky::Utils::command( 'command_not_exists' )
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def test_namerize
|
15
|
-
assert_equal(
|
16
|
-
'Users.fguillen.Develop.Ruby.SweetyBacky.test.fixtures.path',
|
17
|
-
SweetyBacky::Utils.namerize( '/Users/fguillen/Develop/Ruby/SweetyBacky/test/fixtures/path' )
|
15
|
+
assert_equal(
|
16
|
+
'Users.fguillen.Develop.Ruby.SweetyBacky.test.fixtures.path',
|
17
|
+
SweetyBacky::Utils.namerize( '/Users/fguillen/Develop/Ruby/SweetyBacky/test/fixtures/path' )
|
18
18
|
)
|
19
|
-
|
19
|
+
|
20
20
|
assert_equal( 'path', SweetyBacky::Utils.namerize( '/path' ) )
|
21
21
|
assert_equal( 'path', SweetyBacky::Utils.namerize( 'path' ) )
|
22
22
|
end
|
23
|
-
|
24
|
-
end
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -1,110 +1,110 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sweety_backy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 21
|
10
|
-
version: 0.0.21
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.25
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Fernando Guillen
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2018-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0.rc.6
|
20
|
+
type: :development
|
22
21
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
26
24
|
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: -2749782956
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 0
|
32
|
-
- 0
|
33
|
-
- rc
|
34
|
-
- 6
|
25
|
+
- !ruby/object:Gem::Version
|
35
26
|
version: 1.0.0.rc.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
36
34
|
type: :development
|
37
|
-
version_requirements: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: mocha
|
40
35
|
prerelease: false
|
41
|
-
|
42
|
-
|
43
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
44
38
|
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
50
48
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: delorean
|
54
49
|
prerelease: false
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: delorean
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
58
59
|
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
version: "0"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
64
62
|
type: :development
|
65
|
-
version_requirements: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
|
-
name: rake
|
68
63
|
prerelease: false
|
69
|
-
|
70
|
-
|
71
|
-
requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
72
66
|
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
78
76
|
type: :development
|
79
|
-
version_requirements: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: aws-sdk
|
82
77
|
prerelease: false
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: aws-sdk
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
93
89
|
version: 1.7.1
|
94
90
|
type: :runtime
|
95
|
-
|
96
|
-
|
97
|
-
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.7.1
|
97
|
+
description: Simple mechanism to configure and execute backups of folders and MySQL
|
98
|
+
DBs and store them in local folder or S3 bucket
|
99
|
+
email:
|
98
100
|
- fguillen.mail@gmail.com
|
99
|
-
executables:
|
101
|
+
executables:
|
100
102
|
- sweety_backy
|
101
103
|
extensions: []
|
102
|
-
|
103
104
|
extra_rdoc_files: []
|
104
|
-
|
105
|
-
|
106
|
-
- .
|
107
|
-
- .rvmrc_example
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rvmrc_example"
|
108
108
|
- Gemfile
|
109
109
|
- Gemfile.lock
|
110
110
|
- README.md
|
@@ -139,38 +139,28 @@ files:
|
|
139
139
|
- test/utils_test.rb
|
140
140
|
homepage: https://github.com/fguillen/SweetyBacky
|
141
141
|
licenses: []
|
142
|
-
|
142
|
+
metadata: {}
|
143
143
|
post_install_message:
|
144
144
|
rdoc_options: []
|
145
|
-
|
146
|
-
require_paths:
|
145
|
+
require_paths:
|
147
146
|
- lib
|
148
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
-
|
150
|
-
requirements:
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
151
149
|
- - ">="
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
version: "0"
|
157
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
-
none: false
|
159
|
-
requirements:
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
160
154
|
- - ">="
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
|
163
|
-
segments:
|
164
|
-
- 0
|
165
|
-
version: "0"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
166
157
|
requirements: []
|
167
|
-
|
168
158
|
rubyforge_project: SweetyBacky
|
169
|
-
rubygems_version:
|
159
|
+
rubygems_version: 2.5.1
|
170
160
|
signing_key:
|
171
|
-
specification_version:
|
161
|
+
specification_version: 4
|
172
162
|
summary: Ruby backup mechanism
|
173
|
-
test_files:
|
163
|
+
test_files:
|
174
164
|
- test/commander_test.rb
|
175
165
|
- test/fixtures/config_s3.yml
|
176
166
|
- test/fixtures/config_s3_slices.yml
|