backupper 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/bin/backupper +1 -1
- data/lib/backupper/backupper.rb +1 -1
- data/lib/backupper/dump_command.rb +4 -4
- data/lib/backupper/mailer.rb +12 -18
- data/lib/backupper/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a62ccacd902e965abc1f8ca3e2e3cd62c19f7d409a8ce518bb189e12200b026
|
4
|
+
data.tar.gz: 954a6ce0b31a61ff158e06fe6433c31eba02104f256e17f7cbd76e792475f071
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d321d489e3ecd95d652c8e82dc33f691189af99b6ad797aa1f292822a6a1bbf97aa73b9eae2d1bf1260a7cb4b8ddf8eb9065a0d2b533a72e93e44bb8599b97f5
|
7
|
+
data.tar.gz: 8b05b87aab8fabedefc6b60a37edc235ab78c6f59aca215d7caae1bd650c9cbcc0efb45deefb5c89a137327a04af793f0f90c832b12cb6965623bb8e91703a87
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
backupper (0.
|
4
|
+
backupper (0.5.0)
|
5
5
|
mail (~> 2.7)
|
6
6
|
sshkit (~> 1.15)
|
7
7
|
|
@@ -11,12 +11,12 @@ GEM
|
|
11
11
|
byebug (11.0.1)
|
12
12
|
mail (2.7.1)
|
13
13
|
mini_mime (>= 0.1.1)
|
14
|
-
mini_mime (1.
|
15
|
-
net-scp (
|
16
|
-
net-ssh (>= 2.6.5, <
|
17
|
-
net-ssh (
|
14
|
+
mini_mime (1.1.2)
|
15
|
+
net-scp (3.0.0)
|
16
|
+
net-ssh (>= 2.6.5, < 7.0.0)
|
17
|
+
net-ssh (6.1.0)
|
18
18
|
rake (10.5.0)
|
19
|
-
sshkit (1.
|
19
|
+
sshkit (1.21.2)
|
20
20
|
net-scp (>= 1.1.2)
|
21
21
|
net-ssh (>= 2.8.0)
|
22
22
|
|
@@ -31,4 +31,4 @@ DEPENDENCIES
|
|
31
31
|
rake (~> 10.0)
|
32
32
|
|
33
33
|
BUNDLED WITH
|
34
|
-
2.
|
34
|
+
2.3.8
|
data/bin/backupper
CHANGED
data/lib/backupper/backupper.rb
CHANGED
@@ -103,7 +103,7 @@ class Backupper
|
|
103
103
|
def send_report_email!
|
104
104
|
if @report.any? && @mailer['from'] && @mailer['to'] && @mailer['password']
|
105
105
|
begin
|
106
|
-
Mailer.send(from: @mailer['from'], to: @mailer['to'], password: @mailer['password'],
|
106
|
+
Mailer.send(@report, from: @mailer['from'], to: @mailer['to'], password: @mailer['password'], address: @mailer['address'] || 'smtp.gmail.com', port: @mailer['port'] || 587, authentication: @mailer['authentication'] || 'plain')
|
107
107
|
rescue Net::SMTPAuthenticationError => e
|
108
108
|
@logger.error e
|
109
109
|
end
|
@@ -2,17 +2,17 @@ module DumpCommand
|
|
2
2
|
def self.mysql(database:, username: 'root', password: nil, dump_options: nil, outfile:)
|
3
3
|
params = []
|
4
4
|
params << "--databases '#{database}'"
|
5
|
-
params << "-u#{username}"
|
6
|
-
params << "-p#{password}" if password
|
5
|
+
params << "-u'#{username}'"
|
6
|
+
params << "-p'#{password}'" if password
|
7
7
|
params << dump_options if dump_options
|
8
8
|
return "mysqldump #{params.join(' ')} | bzip2 > '#{outfile}'"
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.postgresql(database:, username: 'root', password: nil, dump_options: nil, outfile:)
|
12
12
|
params = []
|
13
|
-
params << "-U #{username}"
|
13
|
+
params << "-U '#{username}'"
|
14
14
|
params << "'#{database}'"
|
15
15
|
params << dump_options if dump_options
|
16
|
-
return "PGPASSWORD
|
16
|
+
return "PGPASSWORD='#{password}' pg_dump #{params.join(' ')} | bzip2 > '#{outfile}'"
|
17
17
|
end
|
18
18
|
end
|
data/lib/backupper/mailer.rb
CHANGED
@@ -1,30 +1,24 @@
|
|
1
1
|
require 'mail'
|
2
2
|
|
3
3
|
class Mailer
|
4
|
-
def self.send(from:, to:, password:,
|
5
|
-
options = {
|
6
|
-
address: 'smtp.gmail.com',
|
7
|
-
port: 587,
|
8
|
-
user_name: from,
|
9
|
-
password: password,
|
10
|
-
authentication: 'plain',
|
11
|
-
enable_starttls_auto: true
|
12
|
-
}
|
4
|
+
def self.send(report, from:, to:, password:, address:, port:, authentication:)
|
13
5
|
Mail.defaults do
|
14
|
-
delivery_method :smtp,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
delivery_method :smtp, {
|
7
|
+
address: address,
|
8
|
+
port: port,
|
9
|
+
user_name: from,
|
10
|
+
password: password,
|
11
|
+
authentication: authentication,
|
12
|
+
enable_starttls_auto: true
|
13
|
+
}
|
21
14
|
end
|
15
|
+
Mail.deliver(to: to, from: from, subject: generate_subject(report), body: generate_body(report))
|
22
16
|
end
|
23
17
|
|
24
18
|
class << self
|
25
19
|
private
|
26
20
|
|
27
|
-
def
|
21
|
+
def generate_body(report)
|
28
22
|
b = []
|
29
23
|
report.each do |k, data|
|
30
24
|
s = ''
|
@@ -51,7 +45,7 @@ class Mailer
|
|
51
45
|
return "Report for backups (#{Time.now})\n\n#{b.join("\n\n")}"
|
52
46
|
end
|
53
47
|
|
54
|
-
def
|
48
|
+
def generate_subject(report)
|
55
49
|
errors = report.select { |_k, v| v[:error] }.size
|
56
50
|
icon = '✅'
|
57
51
|
icon = '⚠️' if errors > 0
|
data/lib/backupper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backupper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pioz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
|
-
rubygems_version: 3.0.
|
125
|
+
rubygems_version: 3.0.1
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Tool to backup databases
|