diff --git a/backup.py b/backup.py index 4208ade..c0b8a2e 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="", icingaOnly=False): +def createBackupScriptStructure(backupList, baseDomain="", icingaOnly=False, backup_no_async_icinga=True): backupPath = "./build/backup/" @@ -107,7 +107,8 @@ def createBackupScriptStructure(backupList, baseDomain="", icingaOnly=False): rsyncScript = rsyncScriptTemplate.render(hostname=hostname, token=icingaToken, hostname_base=hostnameBase, - size_change_commands=sizeChangeNotifyCommands) + size_change_commands=sizeChangeNotifyCommands, + backup_no_async_icinga=backup_no_async_icinga) # build all filter # rsyncFilterAll = rsyncFilterTemplate.render(paths=pathsAll) diff --git a/templates/rsync-backup.sh.j2 b/templates/rsync-backup.sh.j2 index fda95cf..929946e 100644 --- a/templates/rsync-backup.sh.j2 +++ b/templates/rsync-backup.sh.j2 @@ -45,8 +45,10 @@ SERVICE="backup_{{ hostname_base }}" TOKEN="{{ token }}" if [ $RSYNC_SUCCESS -eq 0 ]; then + {% if not backup_no_async_icinga %} curl -H "${CONTENT_TYPE}" -X POST "${ASYNC_ICINGA_ADDRESS}" -d \ "{\"service\": \"${SERVICE}\", \"token\": \"${TOKEN}\", \"status\": \"OK\", \"info\": \"\"}" + {% endif %} # if size changed was copied save new size # {% if not size_change_commands %} @@ -56,8 +58,10 @@ if [ $RSYNC_SUCCESS -eq 0 ]; then {{ cmd }} {% endfor %} else + {% if not backup_no_async_icinga %} curl -H "${CONTENT_TYPE}" -X POST "${ASYNC_ICINGA_ADDRESS}" -d \ "{\"service\": \"${SERVICE}\", \"token\": \"${TOKEN}\", \"status\": \"CRITICAL\", \"info\": \"\"}" + {% endif %} fi cd ..