Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Duehr <stephan.duehr@bareos.com>2022-11-11 12:56:42 +0300
committerStephan Duehr <stephan.duehr@bareos.com>2022-11-11 12:56:42 +0300
commite719a087bc4c9afb6c99b03f95dbe630fd3ee380 (patch)
tree177cb0bca5a3c3d77e41723e9815317596edce64
parent74bca8f15f3dfdedf5138ccfad3047b90190e073 (diff)
VMware Plugin: Fix restore when snapshot existed at backup timedev/sduehr/master/vmware-plugin-enhancements
If a snapshot existed at backup time, the backing filename must be adapted when recreating the VM.
-rw-r--r--core/src/plugins/filed/python/vmware/BareosFdPluginVMware.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/src/plugins/filed/python/vmware/BareosFdPluginVMware.py b/core/src/plugins/filed/python/vmware/BareosFdPluginVMware.py
index b4f12f564..e568828c8 100644
--- a/core/src/plugins/filed/python/vmware/BareosFdPluginVMware.py
+++ b/core/src/plugins/filed/python/vmware/BareosFdPluginVMware.py
@@ -2578,6 +2578,7 @@ class BareosVmConfigInfoToSpec(object):
def __init__(self, config_info):
self.config_info = config_info
self.datastore_rex = re.compile(r"\[(.+?)\]")
+ self.backing_filename_snapshot_rex = re.compile(r"(-\d{6})\.vmdk$")
self.target_datastore_name = None
def transform(self, target_datastore_name=None):
@@ -3026,7 +3027,13 @@ class BareosVmConfigInfoToSpec(object):
device["backing"]["fileName"],
count=1,
)
- add_device.backing.fileName = device["backing"]["fileName"]
+
+ # if a snapshot existed at backup time, the disk backing name will be like
+ # [datastore1] tcl131-test1_1/tcl131-test1-000001.vmdk
+ # the -000001 must be removed when recreating a VM:
+ add_device.backing.fileName = self.backing_filename_snapshot_rex.sub(
+ ".vmdk", device["backing"]["fileName"]
+ )
add_device.backing.digestEnabled = device["backing"]["digestEnabled"]
add_device.backing.diskMode = device["backing"]["diskMode"]
add_device.backing.eagerlyScrub = device["backing"]["eagerlyScrub"]