sg_tiny_backup 1.0.0 → 1.1.0
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.md +6 -0
- data/Gemfile.lock +2 -2
- data/lib/sg_tiny_backup/commands/openssl.rb +2 -2
- data/lib/sg_tiny_backup/commands/zstd.rb +21 -0
- data/lib/sg_tiny_backup/commands.rb +1 -0
- data/lib/sg_tiny_backup/config.rb +15 -3
- data/lib/sg_tiny_backup/pipeline_builders/db.rb +12 -2
- data/lib/sg_tiny_backup/pipeline_builders/log.rb +10 -4
- data/lib/sg_tiny_backup/templates/sg_tiny_backup.yml +3 -2
- data/lib/sg_tiny_backup/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5c04602f890ef4b54a4536d30af0526c4f9ea6c6ad4512f40734b88af1179f2
|
|
4
|
+
data.tar.gz: 775ad8ff272f33d90ed69067548783faff46a481af0099a921ddad0b07b2502c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f4740e9484943da064fd6d590c14e56933405d938027fea254c51ea85eb88e176734803ee2a698ac8f3e4a3f3e7f6840222753cd6f0133cfa38aa54632f9119
|
|
7
|
+
data.tar.gz: a345571e564a4bc303cb3290785dfc6d59e3c86282d458909f5d6b0246b874f2aef4528dd35cba705ebf5f74f1c69a90292aa50825b2b42d1d3d3fa7be8b086a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sg_tiny_backup (1.
|
|
4
|
+
sg_tiny_backup (1.1.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -161,7 +161,7 @@ CHECKSUMS
|
|
|
161
161
|
rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
|
|
162
162
|
rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
|
|
163
163
|
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
164
|
-
sg_tiny_backup (1.
|
|
164
|
+
sg_tiny_backup (1.1.0)
|
|
165
165
|
simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
|
|
166
166
|
simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
|
|
167
167
|
simplecov-lcov (0.9.0) sha256=7a77a31e200a595ed4b0249493056efd0c920601f53d2ef135ca34ee796346cd
|
|
@@ -15,7 +15,7 @@ module SgTinyBackup
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def command
|
|
18
|
-
parts = ["openssl enc -#{CIPHER} -pbkdf2 -iter #{ITER}"]
|
|
18
|
+
parts = ["openssl enc -#{CIPHER} -pbkdf2 -iter #{ITER} -md sha256"]
|
|
19
19
|
parts << "-pass env:SG_TINY_BACKUP_ENCRYPTION_KEY"
|
|
20
20
|
parts << "-out #{@filename}" if @filename
|
|
21
21
|
parts.join(" ")
|
|
@@ -29,7 +29,7 @@ module SgTinyBackup
|
|
|
29
29
|
|
|
30
30
|
class << self
|
|
31
31
|
def decryption_command
|
|
32
|
-
parts = ["openssl enc -d -#{CIPHER} -pbkdf2 -iter #{ITER}"]
|
|
32
|
+
parts = ["openssl enc -d -#{CIPHER} -pbkdf2 -iter #{ITER} -md sha256"]
|
|
33
33
|
parts << "-pass pass:ENCRYPTION_KEY"
|
|
34
34
|
parts << "-in INPUTFILE -out OUTPUTFILE"
|
|
35
35
|
parts.join(" ")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "base"
|
|
4
|
+
|
|
5
|
+
module SgTinyBackup
|
|
6
|
+
module Commands
|
|
7
|
+
class Zstd < Base
|
|
8
|
+
def initialize(level: nil)
|
|
9
|
+
super()
|
|
10
|
+
@level = level
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def command
|
|
14
|
+
parts = ["zstd -c"]
|
|
15
|
+
parts << "--ultra" if @level && @level >= 20
|
|
16
|
+
parts << "-#{@level}" if @level
|
|
17
|
+
parts.join(" ")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -12,10 +12,12 @@ module SgTinyBackup
|
|
|
12
12
|
KEY_FILES = "files"
|
|
13
13
|
KEY_OPTIONAL_FILES = "optional_files"
|
|
14
14
|
KEY_GZIP = "gzip"
|
|
15
|
+
KEY_COMPRESSION = "compression"
|
|
16
|
+
COMPRESSION_DEFAULT = { "method" => "gzip" }.freeze
|
|
15
17
|
|
|
16
|
-
attr_reader :s3, :encryption_key, :pg_dump, :mysqldump, :db, :gzip
|
|
18
|
+
attr_reader :s3, :encryption_key, :pg_dump, :mysqldump, :db, :gzip, :compression
|
|
17
19
|
|
|
18
|
-
def initialize(s3:, encryption_key:, pg_dump: nil, mysqldump: nil, db: nil, log: nil, gzip: nil) # rubocop:disable Metrics/ParameterLists
|
|
20
|
+
def initialize(s3:, encryption_key:, pg_dump: nil, mysqldump: nil, db: nil, log: nil, gzip: nil, compression: nil) # rubocop:disable Metrics/ParameterLists
|
|
19
21
|
@s3 = s3
|
|
20
22
|
@encryption_key = encryption_key
|
|
21
23
|
@pg_dump = pg_dump || {}
|
|
@@ -23,6 +25,15 @@ module SgTinyBackup
|
|
|
23
25
|
@db = db || self.class.rails_db_config
|
|
24
26
|
@log = log || {}
|
|
25
27
|
@gzip = gzip || {}
|
|
28
|
+
@compression =
|
|
29
|
+
if compression
|
|
30
|
+
compression
|
|
31
|
+
elsif gzip
|
|
32
|
+
SgTinyBackup.logger.warn("The 'gzip' configuration is deprecated. Please use 'compression' instead.")
|
|
33
|
+
{ "method" => "gzip", "level" => gzip["level"] }
|
|
34
|
+
else
|
|
35
|
+
COMPRESSION_DEFAULT
|
|
36
|
+
end
|
|
26
37
|
end
|
|
27
38
|
|
|
28
39
|
def log_file_paths
|
|
@@ -43,7 +54,8 @@ module SgTinyBackup
|
|
|
43
54
|
pg_dump: yaml[KEY_PG_DUMP],
|
|
44
55
|
mysqldump: yaml[KEY_MYSQLDUMP],
|
|
45
56
|
log: yaml[KEY_LOG],
|
|
46
|
-
gzip: yaml[KEY_GZIP]
|
|
57
|
+
gzip: yaml[KEY_GZIP],
|
|
58
|
+
compression: yaml[KEY_COMPRESSION]
|
|
47
59
|
)
|
|
48
60
|
end
|
|
49
61
|
|
|
@@ -13,7 +13,7 @@ module SgTinyBackup
|
|
|
13
13
|
basename: basename,
|
|
14
14
|
local: local,
|
|
15
15
|
s3_config: config.s3["db"],
|
|
16
|
-
extension: "sql.gz.enc"
|
|
16
|
+
extension: config.compression["method"] == "zstd" ? "sql.zst.enc" : "sql.gz.enc"
|
|
17
17
|
)
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ module SgTinyBackup
|
|
|
21
21
|
output_path = base_filename if local?
|
|
22
22
|
pl = Pipeline.new(output_path: output_path)
|
|
23
23
|
pl << db_dump_command
|
|
24
|
-
pl <<
|
|
24
|
+
pl << compression_command
|
|
25
25
|
pl << Commands::Openssl.new(password: @config.encryption_key)
|
|
26
26
|
pl << aws_cli_command unless local?
|
|
27
27
|
pl
|
|
@@ -29,6 +29,16 @@ module SgTinyBackup
|
|
|
29
29
|
|
|
30
30
|
private
|
|
31
31
|
|
|
32
|
+
def compression_command
|
|
33
|
+
level = @config.compression["level"]
|
|
34
|
+
case @config.compression["method"]
|
|
35
|
+
when "zstd"
|
|
36
|
+
Commands::Zstd.new(level: level)
|
|
37
|
+
else
|
|
38
|
+
Commands::Gzip.new(level: level)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
32
42
|
def db_dump_command
|
|
33
43
|
db_config = @config.db
|
|
34
44
|
adapter = db_config["adapter"]
|
|
@@ -13,7 +13,7 @@ module SgTinyBackup
|
|
|
13
13
|
basename: basename,
|
|
14
14
|
local: local,
|
|
15
15
|
s3_config: config.s3["log"],
|
|
16
|
-
extension: "tar.gz"
|
|
16
|
+
extension: config.compression["method"] == "zstd" ? "tar.zst" : "tar.gz"
|
|
17
17
|
)
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -21,15 +21,21 @@ module SgTinyBackup
|
|
|
21
21
|
output_path = base_filename if local?
|
|
22
22
|
pl = Pipeline.new(output_path: output_path)
|
|
23
23
|
pl << Commands::Tar.new(paths: @config.log_file_paths, optional_paths: @config.optional_log_file_paths)
|
|
24
|
-
pl <<
|
|
24
|
+
pl << compression_command
|
|
25
25
|
pl << aws_cli_command unless local?
|
|
26
26
|
pl
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
private
|
|
30
30
|
|
|
31
|
-
def
|
|
32
|
-
|
|
31
|
+
def compression_command
|
|
32
|
+
level = @config.compression["level"]
|
|
33
|
+
case @config.compression["method"]
|
|
34
|
+
when "zstd"
|
|
35
|
+
Commands::Zstd.new(level: level)
|
|
36
|
+
else
|
|
37
|
+
Commands::Gzip.new(level: level)
|
|
38
|
+
end
|
|
33
39
|
end
|
|
34
40
|
end
|
|
35
41
|
end
|
|
@@ -32,8 +32,9 @@ pg_dump:
|
|
|
32
32
|
extra_options: -xc --if-exists --encoding=utf8
|
|
33
33
|
mysqldump:
|
|
34
34
|
extra_options: --single-transaction --quick --hex-blob
|
|
35
|
-
#
|
|
36
|
-
#
|
|
35
|
+
# compression:
|
|
36
|
+
# method: gzip # gzip (default) or zstd
|
|
37
|
+
# level: 6 # gzip: 1-9, zstd: 1-22
|
|
37
38
|
# The following settings is not required since database config can be loaded from config/database.yml in typical rails application.
|
|
38
39
|
# db:
|
|
39
40
|
# adapter: postgresql
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sg_tiny_backup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shunichi Ikegami
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Backup postgresql database and logs to S3
|
|
14
14
|
email:
|
|
@@ -42,6 +42,7 @@ files:
|
|
|
42
42
|
- lib/sg_tiny_backup/commands/openssl.rb
|
|
43
43
|
- lib/sg_tiny_backup/commands/pg_dump.rb
|
|
44
44
|
- lib/sg_tiny_backup/commands/tar.rb
|
|
45
|
+
- lib/sg_tiny_backup/commands/zstd.rb
|
|
45
46
|
- lib/sg_tiny_backup/config.rb
|
|
46
47
|
- lib/sg_tiny_backup/error.rb
|
|
47
48
|
- lib/sg_tiny_backup/pipeline.rb
|