Restic: send an email on backup failure
This commit is contained in:
parent
1b68766cd6
commit
6982d0feaa
|
@ -50,6 +50,10 @@ services:
|
||||||
repository: restic
|
repository: restic
|
||||||
version: "1.7.0"
|
version: "1.7.0"
|
||||||
disabled_in_vagrant: true
|
disabled_in_vagrant: true
|
||||||
|
# mail dance
|
||||||
|
domain: "noreply.{{ base_domain }}"
|
||||||
|
allowed_sender_domain: true
|
||||||
|
mail-from: "noreply@noreply.{{ base_domain }}"
|
||||||
|
|
||||||
docker_registry:
|
docker_registry:
|
||||||
domain: "docker.{{ base_domain }}"
|
domain: "docker.{{ base_domain }}"
|
||||||
|
|
|
@ -46,3 +46,19 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0600'
|
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'
|
||||||
|
|
|
@ -15,6 +15,7 @@ services:
|
||||||
--tag datacoop-volumes
|
--tag datacoop-volumes
|
||||||
--exclude '*.tmp'
|
--exclude '*.tmp'
|
||||||
--exclude '/mnt/volumes/mastodon/mastodon_data/cache/'
|
--exclude '/mnt/volumes/mastodon/mastodon_data/cache/'
|
||||||
|
--exclude '/mnt/volumes/restic/'
|
||||||
--verbose
|
--verbose
|
||||||
RESTIC_FORGET_ARGS: >-
|
RESTIC_FORGET_ARGS: >-
|
||||||
--keep-last 10
|
--keep-last 10
|
||||||
|
@ -22,9 +23,13 @@ services:
|
||||||
--keep-weekly 5
|
--keep-weekly 5
|
||||||
--keep-monthly 12
|
--keep-monthly 12
|
||||||
TZ: Europe/Copenhagen
|
TZ: Europe/Copenhagen
|
||||||
|
POST_COMMANDS_FAILURE=/run/libexec/failure.sh
|
||||||
volumes:
|
volumes:
|
||||||
- "./ssh:/run/secrets/.ssh:ro"
|
- "./ssh:/run/secrets/.ssh:ro"
|
||||||
|
- "./scripts:/run/libexec:ro"
|
||||||
- "/docker-volumes:/mnt/volumes:ro"
|
- "/docker-volumes:/mnt/volumes:ro"
|
||||||
|
networks:
|
||||||
|
- postfix
|
||||||
|
|
||||||
prune:
|
prune:
|
||||||
image: mazzolino/restic:{{ services.restic.version }}
|
image: mazzolino/restic:{{ services.restic.version }}
|
||||||
|
@ -36,3 +41,7 @@ services:
|
||||||
TZ: Europe/copenhagen
|
TZ: Europe/copenhagen
|
||||||
volumes:
|
volumes:
|
||||||
- "./ssh:/run/secrets/.ssh:ro"
|
- "./ssh:/run/secrets/.ssh:ro"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
postfix:
|
||||||
|
external: true
|
||||||
|
|
14
roles/docker/templates/restic/failure.sh.j2
Normal file
14
roles/docker/templates/restic/failure.sh.j2
Normal 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
|
Loading…
Reference in a new issue