backupper 0.1.3 → 0.2.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
  SHA1:
3
- metadata.gz: 87540071116c9775a805a84eaafb5d06ecf335d8
4
- data.tar.gz: a76112f17dfcfcd15f971bc95e2fbcb55cc20bc2
3
+ metadata.gz: cf9b9f0ad9102e098e8d9e6e5b01579ae4f5a267
4
+ data.tar.gz: 84d0c5e026bf5fee33cb73daa74af561c72044c7
5
5
  SHA512:
6
- metadata.gz: 9b8be9892a220bd6cb80b51bd79906393a7abaddf52480cadfd39d39b61782ae72aa0f2c274e2e11e82921ee86c24d970b94a79a5225f90e8dc50a4137674ec0
7
- data.tar.gz: 5b4de132ed2370cdaec0e8cd4a2863a56835b3eb0cd9b9bebb8e05b9c9833e266283287054e23a4d89c5f54caae8bc3def3aca9b452f15fcefefcfc3849f0b77
6
+ metadata.gz: 7d4e495caec3e4b74965af5e54b8f8bb7591435c05bda3a698ee46828b8f8653a6e9f6e3e073bf3defcf675726e0c85b3f2a04adddf968dd040b7562ad7b5bb6
7
+ data.tar.gz: 4413eb2020b5db225069607f3be0de358403885707a32581897e8efc495ef0b5f3c918f0a676ac198f170f23932cef191750a3100fc353d0baf14e7df871155f
data/README.md CHANGED
@@ -21,17 +21,18 @@ mailer:
21
21
  password: Pa$$w0rD # Gmail account password
22
22
 
23
23
  db1:
24
- disabled: false # true to disable this backup
25
- dump: '/home/backup/db1' # path where to save the dump of the database
26
- extra_copy: '/mnt/backup-disk/backups/db1' # path where to save a extra copy of the dump
27
- username: user # server ssh username
28
- host: '1.2.3.4' # server ssh ip
29
- port: 22 # server ssh port
30
- password: Pa$$w0rD # server ssh password
31
- adapter: mysql # database to backup (supported are mysql or postgresql)
32
- database: db_name # database name
33
- db_username: db_user # database username
34
- db_password: db_Pa$$w0rD # database password
24
+ disabled: false # true to disable this backup
25
+ dump: '/home/backup/db1' # path where to save the dump of the database
26
+ extra_copy: '/mnt/backup-disk/backups/db1' # path where to save a extra copy of the dump
27
+ username: user # server ssh username
28
+ host: '1.2.3.4' # server ssh ip
29
+ port: 22 # server ssh port
30
+ password: Pa$$w0rD # server ssh password
31
+ adapter: mysql # database to backup (supported are mysql or postgresql)
32
+ database: db_name # database name
33
+ db_username: db_user # database username
34
+ db_password: db_Pa$$w0rD # database password
35
+ dump_options: '--single-transaction --quick' # dump command extra options
35
36
 
36
37
  db2:
37
38
  disabled: false
@@ -1,26 +1,25 @@
1
1
 
2
- lib = File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "backupper/version"
4
+ require 'backupper/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "backupper"
7
+ spec.name = 'backupper'
8
8
  spec.version = Backupper::VERSION
9
- spec.authors = ["pioz"]
10
- spec.email = ["epilotto@gmx.com"]
9
+ spec.authors = ['pioz']
10
+ spec.email = ['epilotto@gmx.com']
11
11
 
12
12
  spec.summary = %q{Tool to backup databases}
13
13
  spec.description = %q{Tool to backup databases}
14
- spec.homepage = "https://github.com/uqido/backupper"
15
- spec.license = "MIT"
14
+ spec.homepage = 'https://github.com/uqido/backupper'
15
+ spec.license = 'MIT'
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
19
  if spec.respond_to?(:metadata)
20
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
21
  else
22
- raise "RubyGems 2.0 or newer is required to protect against " \
23
- "public gem pushes."
22
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
24
23
  end
25
24
 
26
25
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -30,9 +29,9 @@ Gem::Specification.new do |spec|
30
29
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
30
  spec.require_paths = ["lib"]
32
31
 
33
- spec.add_runtime_dependency "sshkit", "~> 1.15"
34
- spec.add_runtime_dependency "mail", "~> 2.7"
32
+ spec.add_runtime_dependency 'sshkit', '~> 1.15'
33
+ spec.add_runtime_dependency 'mail', '~> 2.7'
35
34
 
36
- spec.add_development_dependency "bundler", "~> 1.16"
37
- spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency 'bundler', '~> 1.16'
36
+ spec.add_development_dependency 'rake', '~> 10.0'
38
37
  end
@@ -57,6 +57,7 @@ class Backupper
57
57
  database: o['database'],
58
58
  db_username: o['db_username'],
59
59
  db_password: o['db_password'],
60
+ dump_options: o['dump_options'],
60
61
  outdir: outdir,
61
62
  extra_copy: o['extra_copy']
62
63
  )
@@ -74,23 +75,25 @@ class Backupper
74
75
  end
75
76
  end
76
77
 
77
- def mysql_dump_command(database:, username: 'root', password: nil, outfile:)
78
+ def mysql_dump_command(database:, username: 'root', password: nil, dump_options: nil, outfile:)
78
79
  params = []
79
80
  params << "--databases '#{database}'"
80
81
  params << "-u#{username}"
81
82
  params << "-p#{password}" if password
83
+ params << dump_options if dump_options
82
84
  return "mysqldump #{params.join(' ')} | bzip2 > '#{outfile}'"
83
85
  end
84
86
 
85
- def postgresql_dump_command(database:, username: 'root', password: nil, outfile:)
87
+ def postgresql_dump_command(database:, username: 'root', password: nil, dump_options: nil, outfile:)
86
88
  params = []
87
89
  params << "-U #{username}"
88
90
  params << "-W #{password}" if password
89
91
  params << "'#{database}'"
92
+ params << dump_options if dump_options
90
93
  return "pg_dump #{params.join(' ')} | bzip2 > '#{outfile}'"
91
94
  end
92
95
 
93
- def download_dump(key:, adapter: 'mysql', host:, password: nil, database:, db_username: 'root', db_password: nil, outdir:, extra_copy: nil)
96
+ def download_dump(key:, adapter: 'mysql', host:, password: nil, database:, db_username: 'root', db_password: nil, dump_options: nil, outdir:, extra_copy: nil)
94
97
  if self.respond_to?("#{adapter}_dump_command")
95
98
  t = Time.now
96
99
  path = nil
@@ -101,7 +104,7 @@ class Backupper
101
104
  backupper = self
102
105
  on(host) do |client|
103
106
  client.password = password
104
- execute 'set -o pipefail; ' + backupper.send("#{adapter}_dump_command", database: database, username: db_username, password: db_password, outfile: tempfile)
107
+ execute 'set -o pipefail; ' + backupper.send("#{adapter}_dump_command", database: database, username: db_username, password: db_password, dump_options: dump_options, outfile: tempfile)
105
108
  download! tempfile, path
106
109
  execute :rm, tempfile
107
110
  end
@@ -1,3 +1,3 @@
1
1
  class Backupper
2
- VERSION = "0.1.3"
2
+ VERSION = '0.2.0'
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.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pioz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-02 00:00:00.000000000 Z
11
+ date: 2018-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sshkit