Class: Backups::Restore

Inherits:
Object
  • Object
show all
Defined in:
lib/backups/restore.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Restore

Returns a new instance of Restore.



5
6
7
# File 'lib/backups/restore.rb', line 5

def initialize(name)
  @name = name
end

Instance Method Details

#runObject

Raises:

  • (StandardError)


9
10
11
12
13
14
15
16
# File 'lib/backups/restore.rb', line 9

def run
  raise StandardError, "No backups found" if backups["files"].blank?
  raise StandardError, "File not found" unless service.exist?(key)

  File.open(path, "wb") do |file|
    file.write(ActiveSupport::Gzip.decompress(service.download(key)))
  end
end