mirror of
https://github.com/roles-ansible/ansible_role_restic.git
synced 2024-12-11 23:41:32 +01:00
Fix #45: send email also on the main command failure
This commit is contained in:
parent
cca34cffae
commit
47f548d77e
1 changed files with 7 additions and 0 deletions
|
@ -136,6 +136,13 @@ then
|
||||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') OK" {{ backup_result_log }}
|
echo "$(date -u '+%Y-%m-%d %H:%M:%S') OK" {{ backup_result_log }}
|
||||||
else
|
else
|
||||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" {{ backup_result_log }}
|
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" {{ backup_result_log }}
|
||||||
|
{% if item.mail_on_error is defined and item.mail_on_error == true %}
|
||||||
|
mail -s "restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_hostname }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||||
|
{%- if item.src is defined -%}
|
||||||
|
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
||||||
|
{%- endif -%}
|
||||||
|
{{ ' ' }}Please repair the restic-{{ item.name | replace(' ', '') }} job."
|
||||||
|
{% endif %}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue