webtranslateit-safe 0.4.7 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +9 -0
- data/README.markdown +3 -14
- data/lib/web_translate_it/safe/config/builder.rb +3 -3
- data/lib/web_translate_it/safe/pigz.rb +31 -0
- data/lib/web_translate_it/safe/sftp.rb +21 -14
- data/lib/web_translate_it/safe.rb +9 -7
- metadata +6 -8
- data/lib/web_translate_it/safe/ftp.rb +0 -87
- data/lib/web_translate_it/safe/scp.rb +0 -109
- data/lib/web_translate_it/safe/svndump.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12f0e6be06240bcba9f44a010c0885c9d29459ae7299e91de82c62f13f2d37ec
|
4
|
+
data.tar.gz: aa10fc13934f1ccfa3680a786998973152c317d411227efe9107b7dea0ec8312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c18458f0b32bc78fe6b98cc2fcbae409419da81d1dde870b8aae32a17256523a0f86d667ea5a714b5834cfbbd8653b71576e6b96d6976ae17197c17245609ad
|
7
|
+
data.tar.gz: 36bd512b2581664fadbb55712936ee4b106f59d4daa93873306be81cbe925744c83f780eec0e224da283987cec779837620869158834407dd247fb7f27e08347
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 0.4.9 - 2023-07-06
|
2
|
+
|
3
|
+
* Use pigz instead of gzip when available on system to speed up compression time.
|
4
|
+
## 0.4.8 - 2023-07-05
|
5
|
+
|
6
|
+
* Remove svndump feature.
|
7
|
+
* Remove FTP transfer feature.
|
8
|
+
* Merge SCP with SFTP, add `use_scp` option to SFTP to force SCP transfers.
|
9
|
+
|
1
10
|
## 0.4.7 - 2023-06-30
|
2
11
|
|
3
12
|
* Hotfix.
|
data/README.markdown
CHANGED
@@ -9,6 +9,8 @@ We’ve added:
|
|
9
9
|
- Support for ruby 3.2
|
10
10
|
- Standardized code with rubocop
|
11
11
|
- Added support for SCP transfers — On some conditions with servers with higher latency, transfering large files (> 18GB) with SFTP can take a very long time.
|
12
|
+
- Removed svndump feature
|
13
|
+
- Removed FTP transfer feature
|
12
14
|
|
13
15
|
## Installation
|
14
16
|
|
@@ -132,13 +134,7 @@ safe do
|
|
132
134
|
user "astrails"
|
133
135
|
# port 8023
|
134
136
|
password "ssh password for sftp"
|
135
|
-
|
136
|
-
|
137
|
-
sftp do
|
138
|
-
host "sftp.astrails.com"
|
139
|
-
user "astrails"
|
140
|
-
# port 8023
|
141
|
-
password "ssh password for scp"
|
137
|
+
use_scp: true # use SCP if possible
|
142
138
|
end
|
143
139
|
|
144
140
|
gpg do
|
@@ -156,7 +152,6 @@ safe do
|
|
156
152
|
s3 100
|
157
153
|
cloudfiles 100
|
158
154
|
sftp 100
|
159
|
-
scp 100
|
160
155
|
end
|
161
156
|
|
162
157
|
mysqldump do
|
@@ -176,12 +171,6 @@ safe do
|
|
176
171
|
|
177
172
|
end
|
178
173
|
|
179
|
-
svndump do
|
180
|
-
repo :my_repo do
|
181
|
-
repo_path "/home/svn/my_repo"
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
174
|
pgdump do
|
186
175
|
options "-i -x -O" # -i => ignore version, -x => do not dump privileges (grant/revoke), -O => skip restoration of object ownership in plain text format
|
187
176
|
|
@@ -74,10 +74,10 @@ module WebTranslateIt
|
|
74
74
|
|
75
75
|
simple_value :verbose, :dry_run, :local_only, :path, :command,
|
76
76
|
:options, :user, :host, :port, :password, :key, :secret, :bucket,
|
77
|
-
:api_key, :container, :socket, :service_net, :repo_path
|
77
|
+
:api_key, :container, :socket, :service_net, :repo_path, :use_scp
|
78
78
|
multi_value :skip_tables, :exclude, :files
|
79
|
-
mixed_value :s3, :local, :cloudfiles, :sftp, :mysqldump, :tar, :gpg, :keep, :pgdump, :tar,
|
80
|
-
:
|
79
|
+
mixed_value :s3, :local, :cloudfiles, :sftp, :mysqldump, :tar, :gpg, :keep, :pgdump, :tar,
|
80
|
+
:mongodump
|
81
81
|
collection :database, :archive, :repo
|
82
82
|
|
83
83
|
private
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WebTranslateIt
|
4
|
+
|
5
|
+
module Safe
|
6
|
+
|
7
|
+
class Pigz < Pipe
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def post_process
|
12
|
+
@backup.compressed = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def pipe
|
16
|
+
'|pigz'
|
17
|
+
end
|
18
|
+
|
19
|
+
def extension
|
20
|
+
'.gz'
|
21
|
+
end
|
22
|
+
|
23
|
+
def active?
|
24
|
+
!@backup.compressed && !(find_executable 'pigz').nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -19,7 +19,7 @@ module WebTranslateIt
|
|
19
19
|
def save # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
20
20
|
raise 'pipe-streaming not supported for SFTP.' unless @backup.path
|
21
21
|
|
22
|
-
puts "Uploading #{host}:#{full_path} via SFTP" if verbose? || dry_run?
|
22
|
+
puts "Uploading #{host}:#{full_path} via #{use_scp? ? 'SCP' : 'SFTP'}" if verbose? || dry_run?
|
23
23
|
|
24
24
|
return if dry_run? || local_only?
|
25
25
|
|
@@ -27,10 +27,11 @@ module WebTranslateIt
|
|
27
27
|
opts = {}
|
28
28
|
opts[:password] = password if password
|
29
29
|
opts[:port] = port if port
|
30
|
-
Net::
|
30
|
+
protocol = use_scp? ? Net::SCP : Net::SFTP
|
31
|
+
protocol.start(host, user, opts) do |connexion| # rubocop:todo Metrics/BlockLength
|
31
32
|
puts "Sending #{@backup.path} to #{full_path}" if verbose?
|
32
33
|
begin
|
33
|
-
|
34
|
+
connexion.upload! @backup.path, full_path
|
34
35
|
rescue IO::TimeoutError
|
35
36
|
puts 'Upload timed out, retrying'
|
36
37
|
retries += 1
|
@@ -39,17 +40,19 @@ module WebTranslateIt
|
|
39
40
|
else
|
40
41
|
retry unless retries >= MAX_RETRIES
|
41
42
|
end
|
42
|
-
rescue Net::SFTP::StatusException
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
rescue Net::SFTP::StatusException, Net::SCP::Error
|
44
|
+
Net::SFTP.start(host, user, opts) do |sftp|
|
45
|
+
puts "Ensuring remote path (#{path}) exists" if verbose?
|
46
|
+
# mkdir -p
|
47
|
+
folders = path.split('/')
|
48
|
+
folders.each_index do |i|
|
49
|
+
folder = folders[0..i].join('/')
|
50
|
+
puts "Creating #{folder} on remote" if verbose?
|
51
|
+
begin
|
52
|
+
sftp.mkdir!(folder)
|
53
|
+
rescue StandardError
|
54
|
+
Net::SFTP::StatusException
|
55
|
+
end
|
53
56
|
end
|
54
57
|
end
|
55
58
|
retry
|
@@ -100,6 +103,10 @@ module WebTranslateIt
|
|
100
103
|
config[:sftp, :port]
|
101
104
|
end
|
102
105
|
|
106
|
+
def use_scp?
|
107
|
+
config[:sftp, :use_scp] == true
|
108
|
+
end
|
109
|
+
|
103
110
|
end
|
104
111
|
|
105
112
|
end
|
@@ -5,8 +5,8 @@ require 'net/scp'
|
|
5
5
|
require 'tmpdir'
|
6
6
|
require 'fileutils'
|
7
7
|
require 'benchmark'
|
8
|
-
|
9
8
|
require 'tempfile'
|
9
|
+
require 'mkmf'
|
10
10
|
|
11
11
|
require 'web_translate_it/safe/tmp_file'
|
12
12
|
|
@@ -21,20 +21,23 @@ require 'web_translate_it/safe/source'
|
|
21
21
|
require 'web_translate_it/safe/mysqldump'
|
22
22
|
require 'web_translate_it/safe/pgdump'
|
23
23
|
require 'web_translate_it/safe/archive'
|
24
|
-
require 'web_translate_it/safe/svndump'
|
25
24
|
require 'web_translate_it/safe/mongodump'
|
26
25
|
|
27
26
|
require 'web_translate_it/safe/pipe'
|
28
27
|
require 'web_translate_it/safe/gpg'
|
29
28
|
require 'web_translate_it/safe/gzip'
|
29
|
+
require 'web_translate_it/safe/pigz'
|
30
30
|
|
31
31
|
require 'web_translate_it/safe/sink'
|
32
32
|
require 'web_translate_it/safe/local'
|
33
33
|
require 'web_translate_it/safe/s3'
|
34
34
|
require 'web_translate_it/safe/cloudfiles'
|
35
|
-
require 'web_translate_it/safe/scp'
|
36
35
|
require 'web_translate_it/safe/sftp'
|
37
|
-
|
36
|
+
|
37
|
+
# Keeps mkmf from littering STDOUT
|
38
|
+
MakeMakefile::Logging.quiet = true
|
39
|
+
# Keeps mkmf from creating a mkmf.log file on current path
|
40
|
+
MakeMakefile::Logging.logfile(File::NULL)
|
38
41
|
|
39
42
|
module WebTranslateIt
|
40
43
|
|
@@ -50,12 +53,11 @@ module WebTranslateIt
|
|
50
53
|
[[Mysqldump, %i[mysqldump databases]],
|
51
54
|
[Pgdump, %i[pgdump databases]],
|
52
55
|
[Mongodump, %i[mongodump databases]],
|
53
|
-
[Archive, %i[tar archives]],
|
54
|
-
[Svndump, %i[svndump repos]]].each do |klass, path|
|
56
|
+
[Archive, %i[tar archives]]].each do |klass, path|
|
55
57
|
next unless collection = config[*path]
|
56
58
|
|
57
59
|
collection.each do |name, c|
|
58
|
-
klass.new(name, c).backup.run(c, :gpg, :gzip, :local, :s3, :cloudfiles, :
|
60
|
+
klass.new(name, c).backup.run(c, :gpg, :pigz, :gzip, :local, :s3, :cloudfiles, :sftp)
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webtranslateit-safe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edouard Briere
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-06
|
12
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-s3
|
@@ -68,9 +68,9 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
description: |
|
71
|
-
WebTranslateIt-Safe is a simple tool to backup databases (MySQL and PostgreSQL)
|
72
|
-
Backups can be stored locally or remotely and can be
|
73
|
-
Remote storage is supported on Amazon S3, Rackspace Cloud Files, or just plain
|
71
|
+
WebTranslateIt-Safe is a simple tool to backup databases (MySQL and PostgreSQL) and files.
|
72
|
+
Backups can be stored locally or remotely and can be encrypted.
|
73
|
+
Remote storage is supported on Amazon S3, Rackspace Cloud Files, or just plain SFTP/SCP.
|
74
74
|
email:
|
75
75
|
- support@webtranslateit.com
|
76
76
|
executables:
|
@@ -87,21 +87,19 @@ files:
|
|
87
87
|
- lib/web_translate_it/safe/cloudfiles.rb
|
88
88
|
- lib/web_translate_it/safe/config/builder.rb
|
89
89
|
- lib/web_translate_it/safe/config/node.rb
|
90
|
-
- lib/web_translate_it/safe/ftp.rb
|
91
90
|
- lib/web_translate_it/safe/gpg.rb
|
92
91
|
- lib/web_translate_it/safe/gzip.rb
|
93
92
|
- lib/web_translate_it/safe/local.rb
|
94
93
|
- lib/web_translate_it/safe/mongodump.rb
|
95
94
|
- lib/web_translate_it/safe/mysqldump.rb
|
96
95
|
- lib/web_translate_it/safe/pgdump.rb
|
96
|
+
- lib/web_translate_it/safe/pigz.rb
|
97
97
|
- lib/web_translate_it/safe/pipe.rb
|
98
98
|
- lib/web_translate_it/safe/s3.rb
|
99
|
-
- lib/web_translate_it/safe/scp.rb
|
100
99
|
- lib/web_translate_it/safe/sftp.rb
|
101
100
|
- lib/web_translate_it/safe/sink.rb
|
102
101
|
- lib/web_translate_it/safe/source.rb
|
103
102
|
- lib/web_translate_it/safe/stream.rb
|
104
|
-
- lib/web_translate_it/safe/svndump.rb
|
105
103
|
- lib/web_translate_it/safe/tmp_file.rb
|
106
104
|
homepage: http://github.com/webtranslateit/safe
|
107
105
|
licenses:
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module WebTranslateIt
|
2
|
-
|
3
|
-
module Safe
|
4
|
-
|
5
|
-
class Ftp < Sink
|
6
|
-
|
7
|
-
protected
|
8
|
-
|
9
|
-
def active?
|
10
|
-
host && user
|
11
|
-
end
|
12
|
-
|
13
|
-
def path
|
14
|
-
@path ||= expand(config[:ftp, :path] || config[:local, :path] || ':kind/:id')
|
15
|
-
end
|
16
|
-
|
17
|
-
def save # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
18
|
-
raise 'pipe-streaming not supported for FTP.' unless @backup.path
|
19
|
-
|
20
|
-
puts "Uploading #{host}:#{full_path} via FTP" if verbose? || dry_run?
|
21
|
-
|
22
|
-
return if dry_run? || local_only?
|
23
|
-
|
24
|
-
port ||= 21
|
25
|
-
Net::FTP.open(host) do |ftp|
|
26
|
-
ftp.connect(host, port)
|
27
|
-
ftp.login(user, password)
|
28
|
-
puts "Sending #{@backup.path} to #{full_path}" if verbose?
|
29
|
-
begin
|
30
|
-
ftp.put(@backup.path, full_path)
|
31
|
-
rescue Net::FTPPermError
|
32
|
-
puts "Ensuring remote path (#{path}) exists" if verbose?
|
33
|
-
end
|
34
|
-
end
|
35
|
-
puts '...done' if verbose?
|
36
|
-
end
|
37
|
-
|
38
|
-
# rubocop:todo Metrics/PerceivedComplexity
|
39
|
-
def cleanup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
|
40
|
-
return if local_only? || dry_run?
|
41
|
-
|
42
|
-
return unless keep = config[:keep, :ftp]
|
43
|
-
|
44
|
-
puts "listing files: #{host}:#{base}*" if verbose?
|
45
|
-
port ||= 21
|
46
|
-
Net::FTP.open(host) do |ftp|
|
47
|
-
ftp.connect(host, port)
|
48
|
-
ftp.login(user, password)
|
49
|
-
files = ftp.nlst(path)
|
50
|
-
pattern = File.basename(base.to_s)
|
51
|
-
files = files.select { |x| x.start_with?(pattern) }
|
52
|
-
puts(files.collect { |x| x }) if verbose?
|
53
|
-
|
54
|
-
files = files
|
55
|
-
.collect { |x| x }
|
56
|
-
.sort
|
57
|
-
|
58
|
-
cleanup_with_limit(files, keep) do |f|
|
59
|
-
file = File.join(path, f)
|
60
|
-
puts "removing ftp file #{host}:#{file}" if dry_run? || verbose?
|
61
|
-
ftp.delete(file) unless dry_run? || local_only?
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
66
|
-
|
67
|
-
def host
|
68
|
-
config[:ftp, :host]
|
69
|
-
end
|
70
|
-
|
71
|
-
def user
|
72
|
-
config[:ftp, :user]
|
73
|
-
end
|
74
|
-
|
75
|
-
def password
|
76
|
-
config[:ftp, :password]
|
77
|
-
end
|
78
|
-
|
79
|
-
def port
|
80
|
-
config[:ftp, :port]
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module WebTranslateIt
|
4
|
-
|
5
|
-
module Safe
|
6
|
-
|
7
|
-
class Scp < Sink
|
8
|
-
|
9
|
-
MAX_RETRIES = 5
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
def active?
|
14
|
-
host && user
|
15
|
-
end
|
16
|
-
|
17
|
-
def path
|
18
|
-
@path ||= expand(config[:scp, :path] || config[:local, :path] || ':kind/:id')
|
19
|
-
end
|
20
|
-
|
21
|
-
def save # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
22
|
-
raise 'pipe-streaming not supported for SCP.' unless @backup.path
|
23
|
-
|
24
|
-
puts "Uploading #{host}:#{full_path} via SCP" if verbose? || dry_run?
|
25
|
-
|
26
|
-
return if dry_run? || local_only?
|
27
|
-
|
28
|
-
retries = 0
|
29
|
-
opts = {}
|
30
|
-
opts[:password] = password if password
|
31
|
-
opts[:port] = port if port
|
32
|
-
Net::SCP.start(host, user, opts) do |scp|
|
33
|
-
puts "Sending #{@backup.path} to #{full_path}" if verbose?
|
34
|
-
begin
|
35
|
-
scp.upload! @backup.path, full_path
|
36
|
-
rescue IO::TimeoutError
|
37
|
-
puts 'Upload timed out, retrying'
|
38
|
-
retries += 1
|
39
|
-
if retries >= MAX_RETRIES
|
40
|
-
puts "Tried #{retries} times. Giving up."
|
41
|
-
else
|
42
|
-
retry unless retries >= MAX_RETRIES
|
43
|
-
end
|
44
|
-
rescue Net::SCP::Error
|
45
|
-
puts "Ensuring remote path (#{path}) exists" if verbose?
|
46
|
-
# mkdir -p
|
47
|
-
folders = path.split('/')
|
48
|
-
folders.each_index do |i|
|
49
|
-
folder = folders[0..i].join('/')
|
50
|
-
puts "Creating #{folder} on remote" if verbose?
|
51
|
-
begin
|
52
|
-
scp.mkdir!(folder)
|
53
|
-
rescue StandardError
|
54
|
-
Net::SCP::Error
|
55
|
-
end
|
56
|
-
end
|
57
|
-
retry
|
58
|
-
end
|
59
|
-
end
|
60
|
-
puts '...done' if verbose?
|
61
|
-
end
|
62
|
-
|
63
|
-
# rubocop:todo Metrics/PerceivedComplexity
|
64
|
-
def cleanup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
|
65
|
-
return if local_only? || dry_run?
|
66
|
-
|
67
|
-
return unless (keep = config[:keep, :scp])
|
68
|
-
|
69
|
-
puts "listing files: #{host}:#{base}*" if verbose?
|
70
|
-
opts = {}
|
71
|
-
opts[:password] = password if password
|
72
|
-
opts[:port] = port if port
|
73
|
-
Net::SFTP.start(host, user, opts) do |sftp|
|
74
|
-
files = sftp.dir.glob(path, File.basename("#{base}*"))
|
75
|
-
|
76
|
-
puts files.collect(&:name) if verbose?
|
77
|
-
|
78
|
-
files = files.collect(&:name).sort
|
79
|
-
|
80
|
-
cleanup_with_limit(files, keep) do |f|
|
81
|
-
file = File.join(path, f)
|
82
|
-
puts "removing sftp file #{host}:#{file}" if dry_run? || verbose?
|
83
|
-
sftp.remove!(file) unless dry_run? || local_only?
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
88
|
-
|
89
|
-
def host
|
90
|
-
config[:scp, :host]
|
91
|
-
end
|
92
|
-
|
93
|
-
def user
|
94
|
-
config[:scp, :user]
|
95
|
-
end
|
96
|
-
|
97
|
-
def password
|
98
|
-
config[:scp, :password]
|
99
|
-
end
|
100
|
-
|
101
|
-
def port
|
102
|
-
config[:scp, :port]
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|