10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/bard/backup/destination/upload_destination.rb', line 10
def call
timestamp = now
filename = "#{timestamp.iso8601}.sql.gz"
temp_path = "/tmp/#{filename}"
errors = []
begin
Backhoe.dump(temp_path)
size = File.size(temp_path)
threads = urls.map do |url|
Thread.new do
upload_to_url(url, temp_path)
rescue => e
errors << e
end
end
threads.each(&:join)
ensure
FileUtils.rm_f(temp_path)
end
raise Error, "Upload failed: #{errors.map(&:message).join(", ")}" unless errors.empty?
Bard::Backup.new(timestamp:, size:, destinations: [])
end
|