mirror of
https://github.com/FAUSheppy/athq-vm-management
synced 2025-12-06 05:41:35 +01:00
fix: path selection from map
This commit is contained in:
19
backup.py
19
backup.py
@@ -45,6 +45,7 @@ def createBackupScriptStructure(backupList, baseDomain=""):
|
|||||||
if type(p) == dict:
|
if type(p) == dict:
|
||||||
cur = p["path"]
|
cur = p["path"]
|
||||||
options = p["options"]
|
options = p["options"]
|
||||||
|
#print(hostname, cur, options, 1)
|
||||||
|
|
||||||
if not os.path.isabs(cur):
|
if not os.path.isabs(cur):
|
||||||
print("WARNING: Non-absolute path for backup {} (skipping..)".format(p))
|
print("WARNING: Non-absolute path for backup {} (skipping..)".format(p))
|
||||||
@@ -64,16 +65,18 @@ def createBackupScriptStructure(backupList, baseDomain=""):
|
|||||||
tmpPath += "{}/".format(level)
|
tmpPath += "{}/".format(level)
|
||||||
if not tmpPath == "/":
|
if not tmpPath == "/":
|
||||||
basePaths.append(tmpPath)
|
basePaths.append(tmpPath)
|
||||||
pathsToOptions.update({ tmpPath : options })
|
|
||||||
|
|
||||||
fullPaths.append(cur)
|
fullPaths.append(cur)
|
||||||
pathsToOptions.update({ cur : options })
|
pathsToOptions.update({ "{}\t{}".format(hostname, cur) : options })
|
||||||
|
|
||||||
# keep order (important!)
|
# keep order (important!)
|
||||||
pathsAll = list(set(basePaths)) + [ p.rstrip("/") + "/***" for p in fullPaths ]
|
pathsAll = list(set(basePaths)) + [ p.rstrip("/") + "/***" for p in fullPaths ]
|
||||||
|
|
||||||
filterNoHighData = functools.partial(noHighData, hostname, pathsToOptions)
|
filterNoHighData = functools.partial(noHighData, hostname, pathsToOptions)
|
||||||
filterSizeChanged = functools.partial(sizeChanged, hostname, pathsToOptions)
|
filterSizeChanged = functools.partial(sizeChanged, hostname, pathsToOptions)
|
||||||
|
|
||||||
|
#print(json.dumps(pathsToOptions, indent=2))
|
||||||
|
|
||||||
pathsNoHighData = list(filter(filterNoHighData, pathsAll))
|
pathsNoHighData = list(filter(filterNoHighData, pathsAll))
|
||||||
pathsOnlyIfSizeChanged = list(filter(filterSizeChanged, pathsAll))
|
pathsOnlyIfSizeChanged = list(filter(filterSizeChanged, pathsAll))
|
||||||
pathsMinimal = list(filter(filterSizeChanged, pathsNoHighData))
|
pathsMinimal = list(filter(filterSizeChanged, pathsNoHighData))
|
||||||
@@ -138,20 +141,18 @@ def createBackupScriptStructure(backupList, baseDomain=""):
|
|||||||
# filters #
|
# filters #
|
||||||
def noHighData(hostname, pathsToOptions, path):
|
def noHighData(hostname, pathsToOptions, path):
|
||||||
|
|
||||||
if "*" in path:
|
path = path.replace("*", "")
|
||||||
return True
|
|
||||||
|
|
||||||
options = pathsToOptions[path]
|
options = pathsToOptions.get("{}\t{}".format(hostname, path))
|
||||||
return not (options and "highdata" in options)
|
return not (options and "highdata" in options)
|
||||||
|
|
||||||
def sizeChanged(hostname, pathsToOptions, path):
|
def sizeChanged(hostname, pathsToOptions, path):
|
||||||
|
|
||||||
# keep all generated paths #
|
path = path.replace("*", "")
|
||||||
if "*" in path:
|
|
||||||
return True
|
|
||||||
|
|
||||||
# if there are no options keep it #
|
# if there are no options keep it #
|
||||||
options = pathsToOptions[path]
|
options = pathsToOptions.get("{}\t{}".format(hostname, path))
|
||||||
|
#print(hostname, path, options)
|
||||||
if not options or not "onlyifsizechanged" in options:
|
if not options or not "onlyifsizechanged" in options:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user