diff --git a/backup.py b/backup.py index b1e97c4..1c7441a 100644 --- a/backup.py +++ b/backup.py @@ -6,7 +6,7 @@ import json environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates")) -def createBackupScriptStructure(backupList, baseDomain=""): +def createBackupScriptStructure(backupList, baseDomain="", icingaOnly=False): backupPath = "./build/backup/" @@ -79,6 +79,14 @@ def createBackupScriptStructure(backupList, baseDomain=""): cmd = cmd.format(hostname, cur) sizeChangeNotifyCommands.append(cmd) + # async icinga config # + asyncIcingaConf |= { "backup_{}".format(hostnameBase) : + { "timeout" : "30d", "token" : icingaToken }} + + # continue for icinga only # + if icingaOnly: + continue + # keep order (important!) 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 # rsyncFilterMinimal = rsyncFilterTemplate.render(paths=pathsMinimal) - # async icinga config # - asyncIcingaConf |= { "backup_{}".format(hostnameBase) : - { "timeout" : "30d", "token" : icingaToken }} - # write script # scriptName = "rsync-backup-{}.sh".format(hostnameBase) scriptNames.append(scriptName) @@ -136,7 +140,7 @@ def createBackupScriptStructure(backupList, baseDomain=""): f.write(render) # endfor # - + # write wrapper script # wrapperName = "wrapper.sh" with open(os.path.join(backupPath, wrapperName), "w") as f: diff --git a/main.py b/main.py index 827eb2a..8362ccd 100644 --- a/main.py +++ b/main.py @@ -58,6 +58,6 @@ if __name__ == "__main__": f.write("\n") # backup # - if args.backup: - with open("./config/backup.json") as f: - backup.createBackupScriptStructure(json.load(f), baseDomain=MASTER_ADDRESS) + with open("./config/backup.json") as f: + backup.createBackupScriptStructure(json.load(f), baseDomain=MASTER_ADDRESS, + icingaOnly=not args.backup)