bard-backup 0.16.3 → 0.16.4

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: 799c7d1a31eaf1e721c91aaee1461c92b263a5b3cc09e2de9a30b4d7d15d5a75
4
- data.tar.gz: 441cadada2bbb9eec601cb7871d235e3e91beed18ef0b466222cec6cc61a97c9
3
+ metadata.gz: e86879e3ce9f411f44333fb1fe7f91ca03bcde7a2ce59fd06ecff3195baa57e4
4
+ data.tar.gz: 405a0fd2cef1e33ed766e65594129545198acb5621bdb18ec69990049fe72062
5
5
  SHA512:
6
- metadata.gz: 4008033fe3e3a43124c56cee0ece7a10d11d490f49e15eeee439186c2cf1e09c65f5bb9dfa93905e9811a39ba39e49dcecef05d587f5e8bb3d7862d8a9e97072
7
- data.tar.gz: 53bb19daf1dc24cc4042236d99eb9d4ade2fd3bc4f78733a498613866ded1ae6f4b5f82019323fe6d292f5298ed7f865413a818e1d6d0c867f275d17feb9ec52
6
+ metadata.gz: cb1dd0d3b55864aa3d91b67917d0142cac819eb2e7ad0294192cced323cb486cd4fdfeb9ed3e5d1c207fd854870c28c7e8beace12aa92ff03872277f3d1d3ff1
7
+ data.tar.gz: 6838665c92586d4e0a8a12a197e6ffd780aae8e631cebc73327c729cc78bd6e086e6a1826902bb5ec4efede3c6447af9dc51bacacf2d5c097a25465a7793f4a9
@@ -1,26 +1,37 @@
1
1
  require "backhoe"
2
+ require "bard/config"
3
+ require "fileutils"
4
+ require "tmpdir"
2
5
 
3
6
  module Bard
4
7
  class Backup
5
8
  class CachedLocalBackhoe < Struct.new(:s3_tree, :now)
9
+ class << self
10
+ attr_accessor :dump_dir
11
+ end
12
+
6
13
  def self.call *args
7
14
  new(*args).call
8
15
  end
9
16
 
10
17
  def call
11
- s3_tree.put_file(path, File.basename(path))
18
+ s3_tree.put_file(path, filename)
12
19
  end
13
20
 
14
21
  private
15
22
 
23
+ def filename
24
+ "#{now.iso8601}.sql.gz"
25
+ end
26
+
16
27
  def path
17
- @@path ||= begin
18
- filename = "#{now.iso8601}.sql.gz"
19
- path = "/tmp/#{filename}"
20
- Backhoe.dump path
21
- at_exit { FileUtils.rm_f path }
22
- path
23
- end
28
+ cached = self.class.dump_dir && File.join(self.class.dump_dir, filename)
29
+ return cached if cached && File.exist?(cached)
30
+
31
+ FileUtils.rm_rf(self.class.dump_dir) if self.class.dump_dir
32
+ self.class.dump_dir = dir = Dir.mktmpdir("#{Bard::Config.current.project_name}-backup-")
33
+ at_exit { FileUtils.rm_rf dir }
34
+ File.join(dir, filename).tap { |path| Backhoe.dump path }
24
35
  end
25
36
  end
26
37
  end
@@ -1,13 +1,16 @@
1
1
  require "backhoe"
2
+ require "bard/config"
3
+ require "tmpdir"
2
4
 
3
5
  module Bard
4
6
  class Backup
5
7
  class LocalBackhoe
6
8
  def self.call s3_tree, now
7
- filename = "#{now.iso8601}.sql.gz"
8
- path = "/tmp/#{filename}"
9
- Backhoe.dump path
10
- s3_tree.mv path
9
+ Dir.mktmpdir("#{Bard::Config.current.project_name}-backup-") do |dir|
10
+ path = File.join(dir, "#{now.iso8601}.sql.gz")
11
+ Backhoe.dump path
12
+ s3_tree.mv path
13
+ end
11
14
  end
12
15
  end
13
16
  end
@@ -1,6 +1,6 @@
1
1
  module Bard
2
2
  class Backup
3
- VERSION = "0.16.3"
3
+ VERSION = "0.16.4"
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.3
4
+ version: 0.16.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-11-14 00:00:00.000000000 Z
10
+ date: 2026-11-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: backhoe