bard-backup 0.16.1 → 0.16.3
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/lib/bard/backup/file_tree.rb +11 -7
- data/lib/bard/backup/rekey.rb +8 -2
- data/lib/bard/backup/s3_tree.rb +8 -0
- data/lib/bard/backup/tasks.rake +2 -1
- data/lib/bard/backup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 799c7d1a31eaf1e721c91aaee1461c92b263a5b3cc09e2de9a30b4d7d15d5a75
|
|
4
|
+
data.tar.gz: 441cadada2bbb9eec601cb7871d235e3e91beed18ef0b466222cec6cc61a97c9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4008033fe3e3a43124c56cee0ece7a10d11d490f49e15eeee439186c2cf1e09c65f5bb9dfa93905e9811a39ba39e49dcecef05d587f5e8bb3d7862d8a9e97072
|
|
7
|
+
data.tar.gz: 53bb19daf1dc24cc4042236d99eb9d4ade2fd3bc4f78733a498613866ded1ae6f4b5f82019323fe6d292f5298ed7f865413a818e1d6d0c867f275d17feb9ec52
|
|
@@ -31,13 +31,17 @@ module Bard
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def call
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
File.open("#{MANIFEST_PATH}.lock", File::CREAT | File::RDWR) do |lock|
|
|
35
|
+
return unless lock.flock(File::LOCK_EX | File::LOCK_NB)
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
manifest = load_manifest
|
|
38
|
+
local_files = collect_local_files
|
|
39
|
+
|
|
40
|
+
if manifest.empty?
|
|
41
|
+
sync_from_s3(local_files)
|
|
42
|
+
else
|
|
43
|
+
sync_from_manifest(local_files, manifest)
|
|
44
|
+
end
|
|
41
45
|
end
|
|
42
46
|
end
|
|
43
47
|
|
|
@@ -75,7 +79,7 @@ module Bard
|
|
|
75
79
|
|
|
76
80
|
local_files.each do |path, stat|
|
|
77
81
|
md5 = Digest::MD5.file(path).hexdigest
|
|
78
|
-
unless remote[path] ==
|
|
82
|
+
unless remote[path] == s3_tree.etag_for(path)
|
|
79
83
|
s3_tree.put_file(path, path)
|
|
80
84
|
end
|
|
81
85
|
new_manifest[path] = { "md5" => md5, "mtime" => stat[:mtime], "size" => stat[:size] }
|
data/lib/bard/backup/rekey.rb
CHANGED
|
@@ -10,9 +10,15 @@ module Bard
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def call
|
|
13
|
-
result = { path: tree_config[:path], encrypted: [], skipped: [] }
|
|
13
|
+
result = { path: tree_config[:path], encrypted: [], skipped: [], gone: [] }
|
|
14
14
|
stored_tree.files.each do |file|
|
|
15
|
-
stored =
|
|
15
|
+
stored = begin
|
|
16
|
+
stored_tree.get(file).b
|
|
17
|
+
rescue Aws::S3::Errors::NoSuchKey
|
|
18
|
+
# the hourly backup pruned it after we listed it
|
|
19
|
+
result[:gone] << file
|
|
20
|
+
next
|
|
21
|
+
end
|
|
16
22
|
if under_target_key?(stored)
|
|
17
23
|
result[:skipped] << file
|
|
18
24
|
else
|
data/lib/bard/backup/s3_tree.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require "aws-sdk-s3"
|
|
2
2
|
require "fileutils"
|
|
3
|
+
require "digest/md5"
|
|
3
4
|
require "bard/backup/encryptor"
|
|
4
5
|
|
|
5
6
|
module Bard
|
|
@@ -52,6 +53,13 @@ module Bard
|
|
|
52
53
|
put_body(remote_key, File.binread(local_path))
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
# S3's ETag for a single-part upload is the MD5 of the stored bytes, i.e. the ciphertext when encrypting
|
|
57
|
+
def etag_for(local_path)
|
|
58
|
+
body = File.binread(local_path)
|
|
59
|
+
body = encryptor.encrypt(body) if encryptor
|
|
60
|
+
Digest::MD5.hexdigest(body)
|
|
61
|
+
end
|
|
62
|
+
|
|
55
63
|
def put_body(remote_key, body)
|
|
56
64
|
body = encryptor.encrypt(body) if encryptor
|
|
57
65
|
client.put_object({
|
data/lib/bard/backup/tasks.rake
CHANGED
|
@@ -29,7 +29,8 @@ namespace :bard do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
Bard::Backup.encrypt_existing!(destinations, **Bard::Backup::RailsCredentials.find).each do |result|
|
|
32
|
-
|
|
32
|
+
gone = Array(result[:gone])
|
|
33
|
+
puts "#{result[:path]}: encrypted #{result[:encrypted].size}, already encrypted #{result[:skipped].size}#{", gone before it could be read #{gone.size}" if gone.any?}"
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
36
|
|
data/lib/bard/backup/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bard-backup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.16.
|
|
4
|
+
version: 0.16.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-11-
|
|
10
|
+
date: 2026-11-14 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: backhoe
|