Fri, 19 Jan 2018 10:41:01 +0000
basic config processing
# # Borgend Backup instance # import config from instance import BorgInstance class Backup: def __decode_config(self, cfg): loc0='backup target %d' % self.identifier self.name=config.check_string(cfg, 'name', 'Name', loc0) self.loc='backup target "%s"' % self.name self.repository=config.check_string(cfg, 'repository', 'Target repository', self.loc) self.archive_template=config.check_string(cfg, 'archive_template', 'Archive template', self.loc) self.backup_interval=config.check_nonneg_int(cfg, 'backup_interval', 'Backup interval', self.loc, config.defaults['backup_interval']) self.retry_interval=config.check_nonneg_int(cfg, 'retry_interval', 'Retry interval', self.loc, config.defaults['retry_interval']) self.paths=config.check_nonempty_list_of_strings(cfg, 'paths', 'Paths', self.loc) self.borg_parameters=config.check_list_of_dicts(cfg, 'borg_parameters', 'Borg parameters', self.loc, default=[]) def __init__(self, identifier, cfg): self.identifier=identifier self.__decode_config(cfg) self.config=config self.lastrun=None self.current_instance=None def create(self): if self.current_instance is not None: raise AssertionError('%s running: cannot launch' % self.loc) archive="%s::%s" % (self.repository, self.archive_template) inst=BorgInstance(self.identifier, 'create', self.borg_parameters, archive, self.paths) print(inst.construct_cmdline())