s3-mysql-backup 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/s3_mysql_backup.rb +6 -1
- data/spec/s3_mysql_backup_spec.rb +85 -33
- data/spec/spec_helper.rb +0 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696c4cb78b7a521ed337aeb7348712d338f0c407
|
4
|
+
data.tar.gz: 95743351851fda6539bacb44c259116407e68e3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bab2531ddb39cc3edbb98b2a57c311c91689750e19d5e40ab567ea563eb62260d4708eeaec78c84eba14c6e914d353c1df32587f1736942a7a7f48994f833cf
|
7
|
+
data.tar.gz: cf6fa294ad8877d7c9081ac78e33c159004930030626663cbf84134d63b7b5e99a68005b3127441f2011c6e64697a41995e176e5982a63fe9289684e2c0adb3c
|
data/lib/s3_mysql_backup.rb
CHANGED
@@ -89,7 +89,12 @@ class S3MysqlBackup
|
|
89
89
|
|
90
90
|
smtp = Net::SMTP.new(config["mail_domain"], config["mail_port"])
|
91
91
|
smtp.enable_starttls unless config["mail_start_tls"] == false
|
92
|
-
smtp.start(
|
92
|
+
smtp.start(
|
93
|
+
config["mail_domain"].to_s,
|
94
|
+
config['mail_user'].to_s,
|
95
|
+
config['mail_pass'].to_s,
|
96
|
+
config['mail_authentication'].to_s
|
97
|
+
) do
|
93
98
|
smtp.send_message(content, mail_from, config['mail_to'])
|
94
99
|
end
|
95
100
|
end
|
@@ -2,52 +2,104 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe S3MysqlBackup do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
context "with smtp stubbed" do
|
6
|
+
before :each do
|
7
|
+
@config = YAML::load_file(File.dirname(__FILE__) + '/s3_mysql_backup.yml')
|
8
|
+
stub.instance_of(S3MysqlBackup).config.times(any_times){ @config }
|
8
9
|
|
9
|
-
|
10
|
+
stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(any_times){ true }
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
@dump_file_name = "/tmp/test.20130101.010101.sql.gz"
|
13
|
+
stub.instance_of(S3MysqlBackup).dump_db.times(any_times){ @dump_file_name }
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
mock_stats = Object.new
|
16
|
+
stub(File).stat.with_any_args.times(any_times){ mock_stats }
|
17
|
+
stub(mock_stats).size{ 1024 }
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
mock_utils = Object.new
|
20
|
+
stub(S3Utils).new.with_any_args.times(any_times){ mock_utils }
|
21
|
+
stub.instance_of(S3MysqlBackup).connect_to_s3.times(any_times){ mock_utils }
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#run" do
|
27
|
-
it "should call ensure_backup_dir_exists" do
|
28
|
-
stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(1)
|
29
|
-
S3MysqlBackup.new('test', @config_path).run
|
23
|
+
stub.instance_of(Net::SMTP).enable_starttls.times(any_times)
|
24
|
+
stub.instance_of(Net::SMTP).start.with_any_args.times(any_times){ true }
|
30
25
|
end
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
describe "#run" do
|
28
|
+
it "should call ensure_backup_dir_exists" do
|
29
|
+
stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(1)
|
30
|
+
S3MysqlBackup.new('test', @config_path).run
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should call connect_to_s3" do
|
34
|
+
stub.instance_of(S3MysqlBackup).connect_to_s3.times(1)
|
35
|
+
S3MysqlBackup.new('test', @config_path).run
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
it "should call remove_old_backups" do
|
39
|
+
stub.instance_of(S3MysqlBackup).remove_old_backups.times(1)
|
40
|
+
S3MysqlBackup.new('test', @config_path).run
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should call dump_db" do
|
44
|
+
stub.instance_of(S3MysqlBackup).dump_db.times(1){ @dump_file_name }
|
45
|
+
S3MysqlBackup.new('test', @config_path).run
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should call mail_notification" do
|
49
|
+
stub.instance_of(S3MysqlBackup).mail_notification.times(1)
|
50
|
+
S3MysqlBackup.new('test', @config_path).run
|
51
|
+
end
|
40
52
|
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "without smtp stubbed" do
|
56
|
+
before :each do
|
57
|
+
# @config = YAML::load_file(File.dirname(__FILE__) + '/s3_mysql_backup.yml')
|
58
|
+
# stub.instance_of(S3MysqlBackup).config.times(any_times){ @config }
|
41
59
|
|
42
|
-
|
43
|
-
|
44
|
-
|
60
|
+
stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(any_times){ true }
|
61
|
+
|
62
|
+
@dump_file_name = "/tmp/test.20130101.010101.sql.gz"
|
63
|
+
stub.instance_of(S3MysqlBackup).dump_db.times(any_times){ @dump_file_name }
|
64
|
+
|
65
|
+
mock_stats = Object.new
|
66
|
+
stub(File).stat.with_any_args.times(any_times){ mock_stats }
|
67
|
+
stub(mock_stats).size{ 1024 }
|
68
|
+
|
69
|
+
mock_utils = Object.new
|
70
|
+
stub(S3Utils).new.with_any_args.times(any_times){ mock_utils }
|
71
|
+
stub.instance_of(S3MysqlBackup).connect_to_s3.times(any_times){ mock_utils }
|
72
|
+
|
73
|
+
stub.instance_of(Net::SMTP).send_message.with_any_args.times(any_times)
|
45
74
|
end
|
46
75
|
|
47
|
-
|
48
|
-
|
49
|
-
|
76
|
+
describe "#mail_notification" do
|
77
|
+
it "should not raise with integer password" do
|
78
|
+
expect{
|
79
|
+
|
80
|
+
begin
|
81
|
+
S3MysqlBackup.new('test', {
|
82
|
+
backup_dir: "/tmp/s3_mysql_backups",
|
83
|
+
s3_access_key_id: "my-key",
|
84
|
+
s3_secret_access_key: "my-secret",
|
85
|
+
s3_bucket: "my-bucket",
|
86
|
+
dump_user: "my-user",
|
87
|
+
dump_pass: "my-pass",
|
88
|
+
mail_to: "recipient@example.com",
|
89
|
+
mail_user: "me@gmail.com",
|
90
|
+
mail_pass: 12345,
|
91
|
+
mail_start_tls: true,
|
92
|
+
}
|
93
|
+
).send :mail_notification, "some_file_name"
|
94
|
+
|
95
|
+
rescue Exception => e
|
96
|
+
raise e if e.is_a?(TypeError)
|
97
|
+
end
|
98
|
+
|
99
|
+
}.not_to raise_error
|
100
|
+
end
|
50
101
|
end
|
102
|
+
|
51
103
|
end
|
52
104
|
|
53
105
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3-mysql-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Emminger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.4.
|
91
|
+
rubygems_version: 2.4.7
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: Simple mysql backup to S3
|