mirror of
https://github.com/roles-ansible/ansible_role_restic_archiver.git
synced 2024-08-16 10:09:49 +02:00
Try to improve Mail Reporting
This commit is contained in:
parent
5e3970d2fa
commit
269c04d22f
4 changed files with 37 additions and 10 deletions
22
README.md
22
README.md
|
@ -41,11 +41,11 @@ restic_archiver__repos: {}
|
|||
# keep_within: 1
|
||||
|
||||
# how long should we store all backups by default
|
||||
restic_archiver__keep: 9
|
||||
restic_archiver__keep_hourly: 28
|
||||
restic_archiver__keep_daily: 26
|
||||
restic_archiver__keep: 5
|
||||
restic_archiver__keep_hourly: 16
|
||||
restic_archiver__keep_daily: 14
|
||||
restic_archiver__keep_weekly: 8
|
||||
restic_archiver__keep_monthly: 13
|
||||
restic_archiver__keep_monthly: 16
|
||||
restic_archiver__keep_yearly: 12
|
||||
|
||||
# owner and user of all restic stuff
|
||||
|
@ -67,13 +67,21 @@ restic_archiver__umount_after_usage: false
|
|||
restic_archiver__package:
|
||||
- cron
|
||||
|
||||
restic_archiver__log_output: true
|
||||
restic_archiver__logrotate: true
|
||||
restic_archiver__log_output: true
|
||||
restic_archiver__logrotate: true
|
||||
|
||||
restic_archiver__mailsummary: false
|
||||
restic_archiver__mail_on_error: false
|
||||
restic_archiver__mailaddress: 'root@localhost'
|
||||
|
||||
# restic default options
|
||||
restic_archiver__default_opt: ''
|
||||
|
||||
# additional msgs
|
||||
restic_archiver__additional_mail_msg: ''
|
||||
# version check for this playbook (true is recomended)
|
||||
submodules_versioncheck: false
|
||||
```
|
||||
|
||||
restic_archiver__cache_config: false
|
||||
restic_archiver__cache_dir: '~/.cache/restic'
|
||||
```
|
||||
|
|
|
@ -50,6 +50,7 @@ restic_archiver__log_output: true
|
|||
restic_archiver__logrotate: true
|
||||
|
||||
restic_archiver__mailsummary: false
|
||||
restic_archiver__mail_on_error: false
|
||||
restic_archiver__mailaddress: 'root@localhost'
|
||||
|
||||
# restic default options
|
||||
|
|
|
@ -7,12 +7,17 @@
|
|||
export XDG_CACHE_HOME={{ restic_archiver__cache_dir }}
|
||||
{% endif %}
|
||||
|
||||
{% if restic_archiver__mail_on_error | bool %}
|
||||
# Send a mail on error!
|
||||
restic_archiver__send_mail_on_error=false
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if restic_archiver__mail_report | default(false) %}
|
||||
# This file is also designed to create a overview
|
||||
# over the restic backup and
|
||||
# send it by mail - if wanted
|
||||
found_error=false
|
||||
cat <<EOT > /tmp/mailcontent
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -194,15 +199,20 @@ restic {{ restic_archiver__default_opt }} check
|
|||
{% endif %}
|
||||
|
||||
} || { # catch
|
||||
echo -e "<h1>ALARM, ALRM</h1>\n<h2>SOMETING IN $RESTIC_REPOSITORY went wrong</h2>" >> /tmp/mailcontent
|
||||
awk 'NR==3{print "<h1>ALARM, ALRM</h1>\n<h2>SOMETING IN $RESTIC_REPOSITORY went wrong</h2>"}1' /tmp/mailcontent >> /tmp/mailcontentx
|
||||
echo -e "<h1>ALARM, ALARM</h1>\n<h2>SOMETING IN $RESTIC_REPOSITORY went wrong</h2>" >> /tmp/mailcontent
|
||||
awk 'NR==3{print "<h1>ALARM, ALARM</h1>\n<h2>SOMETING IN $RESTIC_REPOSITORY went wrong</h2>"}1' /tmp/mailcontent >> /tmp/mailcontentx
|
||||
mv /tmp/mailcontentx /tmp/mailcontent
|
||||
found_error=true
|
||||
{% if restic_archiver__mail_on_error | bool %}
|
||||
restic_archiver__send_mail_on_error=true
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
sync
|
||||
|
||||
{% if restic_archiver__mail_report | default(false) %}
|
||||
cat <<EOT >> /tmp/mailcontent
|
||||
<br/><br/><br/>
|
||||
<br/><br/><br/>
|
||||
|
@ -216,7 +226,15 @@ $(df -h)
|
|||
</html>
|
||||
EOT
|
||||
|
||||
|
||||
mail -a "Content-type: text/html" -s "restic backup report" {{ restic_archiver__mailaddress }} < /tmp/mailcontent
|
||||
{% endif %}
|
||||
|
||||
{% if restic_archiver__mail_on_error | bool %}
|
||||
if [ "$restic_archiver__send_mail_on_error" == true ]; then
|
||||
mail -s "restic backup report" {{ restic_archiver__mailaddress }} <<< 'Something went wrong while running restic backup archiver at {{ ansible_hostname }}'
|
||||
fi
|
||||
{% endif %}
|
||||
|
||||
{% if restic_archiver__umount_after_usage %}
|
||||
umount {{ restic_archiver__mount_disk }}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
playbook_version_number: 42 # should be int
|
||||
playbook_version_number: 43 # should be int
|
||||
playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'
|
||||
|
|
Loading…
Reference in a new issue