kamal-backup 0.2.0 → 0.2.1

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: 71b890ee6ff8e37a722f17ea92270d01c6c106fec2a523bf601b8016790646b4
4
- data.tar.gz: 4ac9df9a5f7e9b6b7c9a4b5cab76d23c0555a237885579c5e6ada74968ac1ab6
3
+ metadata.gz: c69dd196192b66424004ae3769d75602862227ad958e056288e1cb49b8242a8a
4
+ data.tar.gz: fa70cfffdf1d95212700244fcdfbb5e7b72b8f4eaf27f2898177c16c305fe9d8
5
5
  SHA512:
6
- metadata.gz: 5f0e231df821c0dae8bcb570fe9a41a221d9e8561fee88b57228de6f045c6fdbc211030e0aae27b8072c881e76714c0665aa26e3daf73f6eff5b8046b955cfdf
7
- data.tar.gz: b86e898c00cd2676a62d91e8c28b207128894907795a483a420280dbedc5c3040e230ad66e6f23fc97831300e2e7805466ab51dd9e7baefd8164b4e49c6dda8e
6
+ metadata.gz: c1764bd5d9a81b9d705838a27f857a679efebe7b2c3ff64be0f4faffc440678e1958124f0cb8ca81c24fa5e30380324d20d42447ae20e5b33f7d946eab7dcec4
7
+ data.tar.gz: f929aecfd15c9b2ed34560292217a97e4ceff31fd4fad1b9ce0e2589af862cd725a45a275c3755ddc744bb8f0e8703c187aa96537664431b93cc4a2841ae4627
@@ -6,6 +6,8 @@ require_relative "command"
6
6
 
7
7
  module KamalBackup
8
8
  class Restic
9
+ RESTIC_ENV_PATTERN = /\A(?:RESTIC_|AWS_|B2_|AZURE_|GOOGLE_|RCLONE_|OS_|ST_|HP_|HTTP_|HTTPS_|NO_PROXY)/i
10
+
9
11
  attr_reader :config, :redactor
10
12
 
11
13
  def initialize(config, redactor:)
@@ -25,13 +27,19 @@ module KamalBackup
25
27
  end
26
28
 
27
29
  def backup_stream(command, filename:, tags:)
28
- restic_command = CommandSpec.new(argv: ["restic", "backup", "--stdin", "--stdin-filename", filename] + tag_args(common_tags + tags))
30
+ restic_command = CommandSpec.new(
31
+ argv: ["restic", "backup", "--stdin", "--stdin-filename", filename] + tag_args(common_tags + tags),
32
+ env: restic_env
33
+ )
29
34
  log("backing up stream as #{filename}")
30
35
  pipe_commands(command, restic_command, producer_label: "dump", consumer_label: "restic backup")
31
36
  end
32
37
 
33
38
  def backup_file(path, filename:, tags:)
34
- command = CommandSpec.new(argv: ["restic", "backup", "--stdin", "--stdin-filename", filename] + tag_args(common_tags + tags))
39
+ command = CommandSpec.new(
40
+ argv: ["restic", "backup", "--stdin", "--stdin-filename", filename] + tag_args(common_tags + tags),
41
+ env: restic_env
42
+ )
35
43
  log("backing up file content as #{filename}")
36
44
 
37
45
  File.open(path, "rb") do |file|
@@ -126,12 +134,12 @@ module KamalBackup
126
134
  end
127
135
 
128
136
  def pipe_dump_to_command(snapshot, filename, command)
129
- restic_command = CommandSpec.new(argv: ["restic", "dump", snapshot, filename])
137
+ restic_command = CommandSpec.new(argv: ["restic", "dump", snapshot, filename], env: restic_env)
130
138
  pipe_commands(restic_command, command, producer_label: "restic dump", consumer_label: command.argv.first)
131
139
  end
132
140
 
133
141
  def write_dump_to_path(snapshot, filename, target_path)
134
- command = CommandSpec.new(argv: ["restic", "dump", snapshot, filename])
142
+ command = CommandSpec.new(argv: ["restic", "dump", snapshot, filename], env: restic_env)
135
143
  target_path = File.expand_path(target_path)
136
144
  FileUtils.mkdir_p(File.dirname(target_path))
137
145
  temp_path = "#{target_path}.kamal-backup-#{$$}.tmp"
@@ -160,7 +168,7 @@ module KamalBackup
160
168
  end
161
169
 
162
170
  def run(args)
163
- Command.capture(CommandSpec.new(argv: ["restic"] + args), redactor: redactor)
171
+ Command.capture(CommandSpec.new(argv: ["restic"] + args, env: restic_env), redactor: redactor)
164
172
  end
165
173
 
166
174
  def common_tags
@@ -172,6 +180,12 @@ module KamalBackup
172
180
  tags.compact.each_with_object([]) { |tag, args| args.concat(["--tag", tag]) }
173
181
  end
174
182
 
183
+ def restic_env
184
+ config.env.each_with_object({}) do |(key, value), env|
185
+ env[key] = value if key.to_s.match?(RESTIC_ENV_PATTERN)
186
+ end
187
+ end
188
+
175
189
  def pipe_commands(producer, consumer, producer_label:, consumer_label:)
176
190
  Open3.popen3(producer.env, *producer.argv) do |producer_stdin, producer_stdout, producer_stderr, producer_wait|
177
191
  producer_stdin.close
@@ -1,3 +1,3 @@
1
1
  module KamalBackup
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamal-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - crmne