--- a/backup.py Mon Jan 22 21:07:34 2018 +0000 +++ b/backup.py Mon Jan 22 22:23:01 2018 +0000 @@ -7,6 +7,7 @@ import time import keyring import borgend +import repository from instance import BorgInstance from threading import Thread, Lock, Condition from scheduler import TerminableThread @@ -55,8 +56,10 @@ self.loc='backup target "%s"' % self._name - self.repository=config.check_string(cfg, 'repository', - 'Target repository', self.loc) + reponame=config.check_string(cfg, 'repository', + 'Target repository', self.loc) + + self.repository=repository.get_controller(reponame) self.archive_prefix=config.check_string(cfg, 'archive_prefix', 'Archive prefix', self.loc) @@ -296,7 +299,7 @@ logger.debug("Launching '%s' on '%s'" % (op['operation'], self._name)) if op['operation']=='create': - archive="%s::%s%s" % (self.repository, + archive="%s::%s%s" % (self.repository.repository_name, self.archive_prefix, self.archive_template) @@ -304,7 +307,7 @@ self.common_parameters+self.create_parameters, self.paths) elif op['operation']=='prune': - self.__do_launch(op, self.repository, + self.__do_launch(op, self.repository.repository_name, ([{'prefix': self.archive_prefix}] + self.common_parameters + self.prune_parameters)) @@ -388,8 +391,8 @@ if self.scheduled_operation: op=self.scheduled_operation self.scheduled_operation=None - self.__launch(op) - + self.repository.queue_action(self._cond, name=self._name, + action=lambda: self.__launch(op)) # Kill a running borg to cause log and result threads to terminate if self.borg_instance: logger.debug("Terminating a borg instance")