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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e342e000d1463ab2e5acda75380d51b4234e15c10bc9926de642657ffadbbe02
4
- data.tar.gz: c5b08c11facbf564daaf375ccff26e0e8ba4aa59b5d03a0981dc8f69ea5d5463
3
+ metadata.gz: 5a62ccacd902e965abc1f8ca3e2e3cd62c19f7d409a8ce518bb189e12200b026
4
+ data.tar.gz: 954a6ce0b31a61ff158e06fe6433c31eba02104f256e17f7cbd76e792475f071
5
5
  SHA512:
6
- metadata.gz: c2c543a27f6f781700acded008b3629a19507da9b10b3851cf513edceac10bcaf8e8efdb771dfee04ae2ee208ba966c5134b03e71002df6d65d3851cbc658a26
7
- data.tar.gz: caccc5dd3ec837854f29efa9e94f11a02543d67c4f6e659f9a5d037760ffe3e5eed577d39eed86151d9e9fb69e5d7ca93d5aaf416adc58386b82dcc49e280269
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.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.0.2)
15
- net-scp (2.0.0)
16
- net-ssh (>= 2.6.5, < 6.0.0)
17
- net-ssh (5.2.0)
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.20.0)
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.0.2
34
+ 2.3.8
data/bin/backupper CHANGED
@@ -21,7 +21,7 @@ begin
21
21
  parser.parse!
22
22
  raise OptionParser::InvalidOption if ARGV.size != 1
23
23
  rescue OptionParser::InvalidOption
24
- puts parser.banner
24
+ puts parser.help
25
25
  exit 1
26
26
  end
27
27
 
@@ -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'], report: @report)
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=#{password} pg_dump #{params.join(' ')} | bzip2 > '#{outfile}'"
16
+ return "PGPASSWORD='#{password}' pg_dump #{params.join(' ')} | bzip2 > '#{outfile}'"
17
17
  end
18
18
  end
@@ -1,30 +1,24 @@
1
1
  require 'mail'
2
2
 
3
3
  class Mailer
4
- def self.send(from:, to:, password:, report:)
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, options
15
- end
16
- Mail.deliver do
17
- to to
18
- from from
19
- subject self.subject(report)
20
- body self.body(report)
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 body(report)
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 subject(report)
48
+ def generate_subject(report)
55
49
  errors = report.select { |_k, v| v[:error] }.size
56
50
  icon = '✅'
57
51
  icon = '⚠️' if errors > 0
@@ -1,3 +1,3 @@
1
1
  class Backupper
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
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.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: 2019-09-10 00:00:00.000000000 Z
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.2
125
+ rubygems_version: 3.0.1
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Tool to backup databases