1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/restic_ynh.git synced 2024-09-03 20:16:22 +02:00
restic_ynh/conf/restic_log.j2
2021-03-07 19:29:16 +01:00

15 lines
481 B
Django/Jinja

#!/bin/bash
set -u
invocation_id=$(systemctl show -p InvocationID --value {{ app }}.service)
hostname=$(hostname)
subject="YunoHost Restic backup log on ${hostname}"
backup_results=$(sudo /bin/journalctl _SYSTEMD_INVOCATION_ID=${invocation_id} | grep -oP '(?<= )[a-zA-Z_-]+: \w+')
echo ${backup_results} | grep -iqE 'error|fail'
if [ "$?" -eq 0 ];then
subject="${subject} (FAIL)"
else
subject="${subject} (SUCCESS)"
fi
echo "${backup_results}" | mail -s "${subject}" root