Skip to content

Commit

Permalink
Merge pull request #46 from lisuml/main
Browse files Browse the repository at this point in the history
Fix #45: send email also on the main command failure
  • Loading branch information
DO1JLR authored Nov 30, 2021
2 parents cca34cf + 47f548d commit 92e62aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions templates/restic_script_Linux.j2
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ then
echo "$(date -u '+%Y-%m-%d %H:%M:%S') OK" {{ backup_result_log }}
else
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


Expand Down

0 comments on commit 92e62aa

Please sign in to comment.