Class: Bard::Backup::Restore
- Inherits:
-
Struct
- Object
- Struct
- Bard::Backup::Restore
- Defined in:
- lib/bard/backup/restore.rb
Overview
Downloads a database backup from S3 and loads it into the local database. The backup nearest at is selected, decrypted if necessary, and loaded via backhoe.
Instance Attribute Summary collapse
-
#at ⇒ Object
Returns the value of attribute at.
-
#destinations ⇒ Object
Returns the value of attribute destinations.
-
#drop_and_create ⇒ Object
Returns the value of attribute drop_and_create.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(at:, drop_and_create: true, destinations: nil) ⇒ Restore
constructor
A new instance of Restore.
Constructor Details
#initialize(at:, drop_and_create: true, destinations: nil) ⇒ Restore
Returns a new instance of Restore.
15 16 17 |
# File 'lib/bard/backup/restore.rb', line 15 def initialize(at:, drop_and_create: true, destinations: nil) super end |
Instance Attribute Details
#at ⇒ Object
Returns the value of attribute at
10 11 12 |
# File 'lib/bard/backup/restore.rb', line 10 def at @at end |
#destinations ⇒ Object
Returns the value of attribute destinations
10 11 12 |
# File 'lib/bard/backup/restore.rb', line 10 def destinations @destinations end |
#drop_and_create ⇒ Object
Returns the value of attribute drop_and_create
10 11 12 |
# File 'lib/bard/backup/restore.rb', line 10 def drop_and_create @drop_and_create end |
Class Method Details
.call ⇒ Object
11 12 13 |
# File 'lib/bard/backup/restore.rb', line 11 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bard/backup/restore.rb', line 19 def call backup = Finder.new(destinations).find(at: at) body = backup[:destination].s3_tree.get(backup[:filename]) path = "/tmp/bard-backup-restore-#{File.basename(backup[:filename])}" File.binwrite(path, body) Backhoe.load(path, drop_and_create: drop_and_create) Bard::Backup.new( timestamp: backup[:timestamp], size: body.bytesize, destinations: [backup[:destination].info], ) ensure FileUtils.rm_f(path) if path end |