Merge "borg-backup: send explicit email on backup failure"

This commit is contained in:
Zuul 2021-02-19 05:20:01 +00:00 committed by Gerrit Code Review
commit 9db55a55f3
2 changed files with 11 additions and 0 deletions

View File

@ -53,6 +53,12 @@
name: '{{ item }}'
with_inventory_hostnames: borg-backup-server
- name: Set cron flag to enable error reports
cron:
name: BORG_UNDER_CRON
env: yes
job: '1'
- name: Install backup cron job
cron:
name: "Run borg backup to {{ item }}"

View File

@ -60,7 +60,12 @@ if [ ${backup_exit} -eq 0 ]; then
info "Backup finished successfully"
else
info "Backup finished with errors"
if [ ${BORG_UNDER_CRON:-0} -eq 1 ]; then
echo "Backups failed on host $(hostname) at $(date)." | \
mail -s "ACTION REQUIRED: Backup failed on $(hostname)" infra-root@openstack.org
fi
fi
exit ${backup_exit}