From a13a02c45ca212c7ac0aae6dfa510219b6c9f46c Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 26 Jan 2022 21:48:48 +0100 Subject: Add a backup script for emails --- app/backup/deploy/backup-daily.hcl | 52 ++++++++++++++++++++++ .../secrets/email/dovecot/backup_aws_access_key_id | 1 + .../email/dovecot/backup_aws_secret_access_key | 1 + .../secrets/email/dovecot/backup_restic_password | 1 + .../secrets/email/dovecot/backup_restic_repository | 1 + 5 files changed, 56 insertions(+) create mode 100644 app/backup/deploy/backup-daily.hcl create mode 100644 app/backup/secrets/email/dovecot/backup_aws_access_key_id create mode 100644 app/backup/secrets/email/dovecot/backup_aws_secret_access_key create mode 100644 app/backup/secrets/email/dovecot/backup_restic_password create mode 100644 app/backup/secrets/email/dovecot/backup_restic_repository (limited to 'app/backup') diff --git a/app/backup/deploy/backup-daily.hcl b/app/backup/deploy/backup-daily.hcl new file mode 100644 index 0000000..a1c2f89 --- /dev/null +++ b/app/backup/deploy/backup-daily.hcl @@ -0,0 +1,52 @@ +job "backup_daily" { + datacenters = ["dc1"] + type = "batch" + periodic { + cron = "@daily" + // Do not allow overlapping runs. + prohibit_overlap = true + } + + task "backup-dovecot" { + constraint { + attribute = "${attr.unique.hostname}" + operator = "=" + value = "digitale" + } + + driver = "docker" + + config { + image = "restic/restic:0.12.1" + entrypoint = [ "/bin/sh", "-c" ] + args = [ "restic backup /mail && restic forget --keep-within 1m1d --keep-within-weekly 3m --keep-within-monthly 1y ; restic prune --max-unused 50% --max-repack-size 2G ; restic check" ] + volumes = [ + "/mnt/ssd/mail:/mail" + ] + } + + + template { + data = <