-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbackup.hcl
72 lines (64 loc) · 1.85 KB
/
backup.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
job "backup" {
datacenters = ["nbg1"]
type = "batch"
priority = 90
periodic {
// Run once a month at midnight in the morning of the first of the month
cron = "@monthly"
}
group "main" {
restart {
delay = "1h"
}
ephemeral_disk {
sticky = true
migrate = true
}
task "restic" {
driver = "raw_exec"
config {
command = "bash"
args = ["secrets/do-backup.sh"]
}
vault {
policies = ["backup-cluster"]
}
template {
destination = "secrets/env"
env = true
data = <<-EOF
{{ with secret "kv/backup/repository" }}
AWS_ACCESS_KEY_ID={{ .Data.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY={{ .Data.aws_secret_access_key }}
RESTIC_REPOSITORY={{ .Data.restic_repository }}
RESTIC_PASSWORD={{ .Data.restic_password }}
RESTIC_CACHE_DIR={{ env "NOMAD_ALLOC_DIR" }}
{{ end }}
EOF
}
template {
destination = "local/excludes.txt"
data = <<-EOF
# Ignore allocation ephemeral storage
/opt/nomad/alloc
EOF
}
template {
destination = "secrets/do-backup.sh"
perms = "755"
data = <<-EOF
#!/bin/bash
exec 2>&1
set -uexo pipefail
restic version
wg-quick save /etc/wireguard/wg0.conf
restic backup --verbose /opt /etc /home/ubuntu --exclude-file=local/excludes.txt --exclude-caches -o s3.storage-class=STANDARD_IA
# This is pressently commented out because it has no effect yet.
# Ideally, restic 0.12 will be installed when uncommenting it, since
# that has substantial prune performance improvements.
# restic forget --keep-monthly=12 --prune
EOF
}
}
}
}