Class: Bitferry::Restic::Backup
Constant Summary
collapse
- PROCESS =
{
default: ['--no-cache']
}
- FORGET =
{
default: ['--prune', '--no-cache', '--keep-within-hourly', '24h', '--keep-within-daily', '7d', '--keep-within-weekly', '30d', '--keep-within-monthly', '1y', '--keep-within-yearly', '100y']
}
- CHECK =
{
default: ['--no-cache'],
full: ['--no-cache', '--read-data']
}
Constants inherited
from Task
Task::ROUTE
Instance Attribute Summary collapse
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, #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=
Instance Attribute Details
#check_options ⇒ Object
Returns the value of attribute check_options.
1181
1182
1183
|
# File 'lib/bitferry.rb', line 1181
def check_options
@check_options
end
|
#forget_options ⇒ Object
Returns the value of attribute forget_options.
1180
1181
1182
|
# File 'lib/bitferry.rb', line 1180
def forget_options
@forget_options
end
|
Instance Method Details
#common_options_simulate ⇒ Object
1228
|
# File 'lib/bitferry.rb', line 1228
def common_options_simulate = common_options + [Bitferry.simulate? ? '--dry-run' : nil].compact
|
#create(*args, format: nil, process: nil, forget: nil, check: nil, **opts) ⇒ Object
1184
1185
1186
1187
1188
1189
1190
|
# File 'lib/bitferry.rb', line 1184
def create(*args, format: nil, process: nil, forget: nil, check: nil, **opts)
super(*args, **opts)
@format = format
@process_options = Bitferry.optional(process, PROCESS)
@forget_options = Bitferry.optional(forget, FORGET)
@check_options = Bitferry.optional(check, CHECK)
end
|
#exclude_filters ⇒ Object
1193
|
# File 'lib/bitferry.rb', line 1193
def exclude_filters = ([Volume::STORAGE, Volume::STORAGE_] + exclude).collect { |x| ['--exclude', x]}.flatten
|
#externalize ⇒ Object
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
|
# File 'lib/bitferry.rb', line 1231
def externalize
restic = {
process: process_options,
forget: forget_options,
check: check_options
}.compact
super.merge({
operation: :backup,
restic: restic.empty? ? nil : restic
}.compact)
end
|
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
|
# File 'lib/bitferry.rb', line 1253
def format
if Bitferry.simulate?
log.info('skipped repository initialization (simulation)')
else
log.info("initializing repository for task #{tag}")
if @format == true
log.debug("wiping repository in #{repository.root}")
['config', 'data', 'index', 'keys', 'locks', 'snapshots'].each { |x| FileUtils.rm_rf(File.join(repository.root.to_s, x)) }
end
if @format == false
log.info("attached to existing repository for task #{tag} in #{repository.root}")
else
begin
execute(*common_options, 'init')
log.info("initialized repository for task #{tag} in #{repository.root}")
rescue
log.fatal("failed to initialize repository for task #{tag} in #{repository.root}")
raise
end
end
end
@state = :intact
end
|
#process ⇒ Object
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
|
# File 'lib/bitferry.rb', line 1209
def process
begin
log.info("processing task #{tag}")
execute('backup', '.', '--tag', "bitferry,#{tag}", *exclude_filters, *process_options, *common_options_simulate, chdir: directory.root)
unless check_options.nil?
log.info("checking repository in #{repository.root}")
execute('check', *check_options, *common_options)
end
unless forget_options.nil?
log.info("performing repository maintenance tasks in #{repository.root}")
execute('forget', '--tag', "bitferry,#{tag}", *forget_options.collect(&:to_s), *common_options_simulate)
end
true
rescue
false
end
end
|
#restore(hash) ⇒ Object
1244
1245
1246
1247
1248
1249
1250
|
# File 'lib/bitferry.rb', line 1244
def restore(hash)
super
opts = hash.fetch(:restic, {})
@process_options = opts[:process]
@forget_options = opts[:forget]
@check_options = opts[:check]
end
|
#show_direction ⇒ Object
1202
|
# File 'lib/bitferry.rb', line 1202
def show_direction = '-->'
|
#show_operation ⇒ Object
1199
|
# File 'lib/bitferry.rb', line 1199
def show_operation = 'encrypt+backup'
|
#show_status ⇒ Object
1196
|
# File 'lib/bitferry.rb', line 1196
def show_status = "#{show_operation} #{directory.show_status} #{show_direction} #{repository.show_status} #{show_filters}"
|