From 58a09ee3d34439ddce8391d375c0028bd242e3f2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 20 Oct 2020 12:02:14 +0200 Subject: targets: move the graft/reparent handling to lxc/lvm target It is specific to that target and does not belong with common save code. --- lbup/targets.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lbup/targets.py b/lbup/targets.py index 59db6db..f6f7e82 100644 --- a/lbup/targets.py +++ b/lbup/targets.py @@ -82,13 +82,12 @@ class Target(ABC): self._logger.debug('%s stderr: %s' % (name, sanitize(stderr))) def _do_save(self, bup_exec, dry_run, *, - reparent = None, index_opts = None, save_opts = None): - dirs = self.dirs - excludes = self.excludes - if reparent is not None: - dirs = [d.reparent(*reparent) for d in dirs] - excludes = [d.reparent(*reparent) for d in excludes] - + dirs = None, excludes = None, + index_opts = None, save_opts = None): + if dirs is None: + dirs = self.dirs + if excludes is None: + excludes = self.excludes if index_opts is None: index_opts = [] if save_opts is None: @@ -377,15 +376,19 @@ class TargetSSHLVM(TargetSSH): self._logger.debug('Backup targets are at device %s(%s), mounted at %s', "%d:%d" % (devnum >> 8, devnum & 255), fstype, mountpoint) + bup_exec = ['bup', 'on', '%s@%s' % (self._remote.username, self._remote.host), + '-d', bupdir] + save_opts = ['--graft=%s=%s' % (snapshot_mount, mountpoint)] + index_opts = ['--no-check-device'] + reparent = (mountpoint, AbsPath(snapshot_mount)) + dirs = [d.reparent(*reparent) for d in self.dirs] + excludes = [d.reparent(*reparent) for d in self.excludes] + stack.enter_context(self._mount_snapshot(conn_root, devnum, snapshot_mount, fstype)) - bup_exec = ['bup', 'on', '%s@%s' % (self._remote.username, self._remote.host), - '-d', bupdir] - reparent = (mountpoint, AbsPath(snapshot_mount)) return self._do_save(bup_exec, dry_run, - reparent = reparent, - save_opts = ['--graft=%s=%s' % (snapshot_mount, mountpoint)], - index_opts = ['--no-check-device']) + dirs = dirs, excludes = excludes, + save_opts = save_opts, index_opts = index_opts) class TargetSSHLXCLVM(TargetSSHLVM): """ -- cgit v1.2.3