mirror of
https://github.com/FAUSheppy/athq-vm-management
synced 2025-12-09 06:58:32 +01:00
fix: generate backup icinga independant of args flag
This commit is contained in:
14
backup.py
14
backup.py
@@ -6,7 +6,7 @@ import json
|
|||||||
|
|
||||||
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates"))
|
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates"))
|
||||||
|
|
||||||
def createBackupScriptStructure(backupList, baseDomain=""):
|
def createBackupScriptStructure(backupList, baseDomain="", icingaOnly=False):
|
||||||
|
|
||||||
|
|
||||||
backupPath = "./build/backup/"
|
backupPath = "./build/backup/"
|
||||||
@@ -79,6 +79,14 @@ def createBackupScriptStructure(backupList, baseDomain=""):
|
|||||||
cmd = cmd.format(hostname, cur)
|
cmd = cmd.format(hostname, cur)
|
||||||
sizeChangeNotifyCommands.append(cmd)
|
sizeChangeNotifyCommands.append(cmd)
|
||||||
|
|
||||||
|
# async icinga config #
|
||||||
|
asyncIcingaConf |= { "backup_{}".format(hostnameBase) :
|
||||||
|
{ "timeout" : "30d", "token" : icingaToken }}
|
||||||
|
|
||||||
|
# continue for icinga only #
|
||||||
|
if icingaOnly:
|
||||||
|
continue
|
||||||
|
|
||||||
# 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 ]
|
||||||
|
|
||||||
@@ -107,10 +115,6 @@ def createBackupScriptStructure(backupList, baseDomain=""):
|
|||||||
# build filter without high data and without non-size-changed dirs #
|
# build filter without high data and without non-size-changed dirs #
|
||||||
rsyncFilterMinimal = rsyncFilterTemplate.render(paths=pathsMinimal)
|
rsyncFilterMinimal = rsyncFilterTemplate.render(paths=pathsMinimal)
|
||||||
|
|
||||||
# async icinga config #
|
|
||||||
asyncIcingaConf |= { "backup_{}".format(hostnameBase) :
|
|
||||||
{ "timeout" : "30d", "token" : icingaToken }}
|
|
||||||
|
|
||||||
# write script #
|
# write script #
|
||||||
scriptName = "rsync-backup-{}.sh".format(hostnameBase)
|
scriptName = "rsync-backup-{}.sh".format(hostnameBase)
|
||||||
scriptNames.append(scriptName)
|
scriptNames.append(scriptName)
|
||||||
|
|||||||
4
main.py
4
main.py
@@ -58,6 +58,6 @@ if __name__ == "__main__":
|
|||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
# backup #
|
# backup #
|
||||||
if args.backup:
|
|
||||||
with open("./config/backup.json") as f:
|
with open("./config/backup.json") as f:
|
||||||
backup.createBackupScriptStructure(json.load(f), baseDomain=MASTER_ADDRESS)
|
backup.createBackupScriptStructure(json.load(f), baseDomain=MASTER_ADDRESS,
|
||||||
|
icingaOnly=not args.backup)
|
||||||
|
|||||||
Reference in New Issue
Block a user