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

Constructor Details

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

Instance Method Details

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



1244
1245
1246
1247
# File 'lib/bitferry.rb', line 1244

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

#exclude_filtersObject



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

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

#externalizeObject



1262
1263
1264
1265
1266
1267
1268
1269
1270
# File 'lib/bitferry.rb', line 1262

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

#processObject



1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
# File 'lib/bitferry.rb', line 1280

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



1273
1274
1275
1276
1277
# File 'lib/bitferry.rb', line 1273

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

#show_directionObject



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

def show_direction = '-->'

#show_operationObject



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

def show_operation = 'decrypt+restore'

#show_statusObject



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

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