summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-10-20 12:02:14 +0200
committerAnton Khirnov <anton@khirnov.net>2020-10-20 12:02:14 +0200
commit58a09ee3d34439ddce8391d375c0028bd242e3f2 (patch)
tree1e3f1b308960667dbf94bbab9bef7f336bc72a78
parent2ec39a6058d8d778e27945ddb43c6448ed61aabe (diff)
targets: move the graft/reparent handling to lxc/lvm target
It is specific to that target and does not belong with common save code.
-rw-r--r--lbup/targets.py29
1 files 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):
"""