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 +4 -4
- data/README.md +12 -11
- data/backupper.gemspec +13 -14
- data/lib/backupper/backupper.rb +7 -4
- data/lib/backupper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf9b9f0ad9102e098e8d9e6e5b01579ae4f5a267
|
4
|
+
data.tar.gz: 84d0c5e026bf5fee33cb73daa74af561c72044c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
25
|
-
dump: '/home/backup/db1'
|
26
|
-
extra_copy: '/mnt/backup-disk/backups/db1'
|
27
|
-
username: user
|
28
|
-
host: '1.2.3.4'
|
29
|
-
port: 22
|
30
|
-
password: Pa$$w0rD
|
31
|
-
adapter: mysql
|
32
|
-
database: db_name
|
33
|
-
db_username: db_user
|
34
|
-
db_password: db_Pa$$w0rD
|
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
|
data/backupper.gemspec
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require 'backupper/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'backupper'
|
8
8
|
spec.version = Backupper::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
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 =
|
15
|
-
spec.license =
|
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[
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
21
|
else
|
22
|
-
raise
|
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
|
34
|
-
spec.add_runtime_dependency
|
32
|
+
spec.add_runtime_dependency 'sshkit', '~> 1.15'
|
33
|
+
spec.add_runtime_dependency 'mail', '~> 2.7'
|
35
34
|
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
38
37
|
end
|
data/lib/backupper/backupper.rb
CHANGED
@@ -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
|
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.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-
|
11
|
+
date: 2018-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sshkit
|