Restic: send an email on backup failure

This commit is contained in:
Reynir Björnsson 2024-03-03 21:17:48 +01:00
parent 1b68766cd6
commit 6982d0feaa
4 changed files with 43 additions and 0 deletions

View File

@ -50,6 +50,10 @@ services:
repository: restic
version: "1.7.0"
disabled_in_vagrant: true
# mail dance
domain: "noreply.{{ base_domain }}"
allowed_sender_domain: true
mail-from: "noreply@noreply.{{ base_domain }}"
docker_registry:
domain: "docker.{{ base_domain }}"

View File

@ -46,3 +46,19 @@
owner: root
group: root
mode: '0600'
- name: Create scripts directory
file:
path: "{{ services.restic.volume_folder }}/scripts"
owner: root
group: root
mode: '0755'
state: directory
- name: Upload failure.sh script
template:
src: restic/failure.sh.j2
dest: "{{ services.restic.volume_folder }}/scripts/failure.sh"
owner: root
group: root
mode: '0755'

View File

@ -15,6 +15,7 @@ services:
--tag datacoop-volumes
--exclude '*.tmp'
--exclude '/mnt/volumes/mastodon/mastodon_data/cache/'
--exclude '/mnt/volumes/restic/'
--verbose
RESTIC_FORGET_ARGS: >-
--keep-last 10
@ -22,9 +23,13 @@ services:
--keep-weekly 5
--keep-monthly 12
TZ: Europe/Copenhagen
POST_COMMANDS_FAILURE=/run/libexec/failure.sh
volumes:
- "./ssh:/run/secrets/.ssh:ro"
- "./scripts:/run/libexec:ro"
- "/docker-volumes:/mnt/volumes:ro"
networks:
- postfix
prune:
image: mazzolino/restic:{{ services.restic.version }}
@ -36,3 +41,7 @@ services:
TZ: Europe/copenhagen
volumes:
- "./ssh:/run/secrets/.ssh:ro"
networks:
postfix:
external: true

View File

@ -0,0 +1,14 @@
#!/bin/sh
curl smtp://postfix --mail-from {{ services.restic.mail-from }} --mail-rcpt admin-hold@data.coop --upload-file . << END_OF_MAIL
From: Restic backup <{{ services.restic.mail-from }}>
To: admin-hold@data.coop
Subject: Restic backup failed
Date: $(date)
Dear sir or madam,
Tonight's backup failed!
Best,
Your backup software.
END_OF_MAIL