Compare commits

...

5 commits

Author SHA1 Message Date
Reynir Björnsson d468e49830 . 2024-03-04 14:15:52 +01:00
Reynir Björnsson ae497f0284 . 2024-03-04 13:30:58 +01:00
Reynir Björnsson ac64706fcb . 2024-03-04 12:48:51 +01:00
Reynir Björnsson 9fb16d3a69 Address comments by @samsapti
We need to use ':' instead of '=' in yaml for environment variable
bindings.
Spurious tab where it should be all spaces
Rename variable mail-from to mail_from to align with existing code style
Nit: change email addresses
2024-03-04 09:20:04 +01:00
Reynir Björnsson 6982d0feaa Restic: send an email on backup failure 2024-03-03 21:17:48 +01:00
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: "backup@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://{{ smtp_host }} --mail-from {{ services.restic.mail_from }} --mail-rcpt admin@data.coop --upload-file . << END_OF_MAIL
From: Restic backup <{{ services.restic.mail_from }}>
To: admin@data.coop
Subject: Restic backup failed
Date: $(date)
Dear sir or madam,
Tonight's backup failed!
Best,
Your backup software.
END_OF_MAIL