Class: Bitferry::Restic::Restore

Inherits:
Task
  • Object
show all
Defined in:
lib/bitferry.rb

Constant Summary collapse

PROCESS =
{
  default: ['--no-cache', '--sparse']
}

Constants inherited from Task

Task::ROUTE

Instance Attribute Summary

Attributes inherited from Task

#directory, #repository

Attributes inherited from Task

#exclude, #generation, #include, #modified, #tag

Instance Method Summary collapse

Methods inherited from Task

#common_options, #execute, #format, #include_filters, #initialize, #intact?, #password, #refers?, #touch

Methods inherited from Task

[], #commit, #delete, delete, #initialize, intact, live, #live?, lookup, match, new, #process_options, register, registered, reset, restore, #restore_endpoint, #show_filters, stale, #touch

Methods included from Logging

log, #log, log=

Constructor Details

This class inherits a constructor from Bitferry::Restic::Task

Instance Method Details

#create(*args, process: nil, **opts) ⇒ Object



1291
1292
1293
1294
# File 'lib/bitferry.rb', line 1291

def create(*args, process: nil, **opts)
  super(*args, **opts)
  @process_options = Bitferry.optional(process, PROCESS)
end

#exclude_filtersObject



1297
# File 'lib/bitferry.rb', line 1297

def exclude_filters = exclude.collect { |x| ['--exclude', x] }.flatten

#externalizeObject



1313
1314
1315
1316
1317
1318
1319
1320
1321
# File 'lib/bitferry.rb', line 1313

def externalize
  restic = {
    process: process_options
  }.compact
  super.merge({
    operation: :restore,
    restic: restic.empty? ? nil : restic
  }.compact)
end

#processObject



1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
# File 'lib/bitferry.rb', line 1331

def process
  log.info("processing task #{tag}")
  begin
    # FIXME restore specifically tagged latest snapshot
    execute('restore', 'latest', '--target', directory.root.to_s, *include_filters, *exclude_filters, *process_options, *common_options, simulate: Bitferry.simulate?)
    true
  rescue
    false
  end
end

#restore(hash) ⇒ Object



1324
1325
1326
1327
1328
# File 'lib/bitferry.rb', line 1324

def restore(hash)
  super
  opts = hash.fetch(:rclone, {})
  @process_options = opts[:process]
end

#show_directionObject



1306
# File 'lib/bitferry.rb', line 1306

def show_direction = '-->'

#show_operationObject



1303
# File 'lib/bitferry.rb', line 1303

def show_operation = 'decrypt+restore'

#show_statusObject



1300
# File 'lib/bitferry.rb', line 1300

def show_status = "#{show_operation} #{repository.show_status} #{show_direction} #{directory.show_status} #{show_filters}"