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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49442669d72632f005a9259c655718af2a0e3ef83031ba765b9417b129ae3575
4
- data.tar.gz: 10e4f231663300b9a0b7d503eb311bf7cc743ab55282980c998729985712f364
3
+ metadata.gz: 799c7d1a31eaf1e721c91aaee1461c92b263a5b3cc09e2de9a30b4d7d15d5a75
4
+ data.tar.gz: 441cadada2bbb9eec601cb7871d235e3e91beed18ef0b466222cec6cc61a97c9
5
5
  SHA512:
6
- metadata.gz: 4fc3080141bd0471bd4aca59f9ff357cd1b489948a9db928d32326d906e91f9135292f2852478ad3781c251d10318580a0ef613098cbe0d937a3b397300040c0
7
- data.tar.gz: cdee3abbb2a48566211df4201738d45b82be2e6370b58e73d73fa4a4e7fa5c493279935b8d946aa8be3756bf4608ddb542a7a3aaf3cca9b546fb772c75ff164a
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
- manifest = load_manifest
35
- local_files = collect_local_files
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
- if manifest.empty?
38
- sync_from_s3(local_files)
39
- else
40
- sync_from_manifest(local_files, manifest)
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] == md5
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] }
@@ -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 = stored_tree.get(file).b
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
@@ -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({
@@ -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
- puts "#{result[:path]}: encrypted #{result[:encrypted].size}, already encrypted #{result[:skipped].size}"
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
 
@@ -1,6 +1,6 @@
1
1
  module Bard
2
2
  class Backup
3
- VERSION = "0.16.1"
3
+ VERSION = "0.16.3"
4
4
  end
5
5
  end
6
6
 
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.1
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-13 00:00:00.000000000 Z
10
+ date: 2026-11-14 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: backhoe