homelab/nomad-job/backup-postgress.nomad

59 lines
1.2 KiB
Plaintext
Raw Normal View History

2022-10-29 08:39:47 +00:00
job "backup-postgress" {
datacenters = ["homelab"]
priority = 50
type = "batch"
meta {
forcedeploy = "0"
}
2024-02-21 18:02:08 +00:00
constraint {
attribute = "${node.class}"
operator = "set_contains"
value = "cluster"
}
2022-10-29 08:39:47 +00:00
constraint {
attribute = "${attr.cpu.arch}"
value = "amd64"
}
periodic {
2023-11-01 07:42:04 +00:00
crons = ["0 3 * * *"]
2022-10-29 08:39:47 +00:00
prohibit_overlap = true
}
group "backup-postgress" {
network {
mode = "host"
}
vault {
2022-10-30 08:33:39 +00:00
policies = ["dump"]
2022-10-29 08:39:47 +00:00
}
task "backup" {
driver = "docker"
service {
name = "backup-postgress"
}
config {
2024-03-17 17:58:24 +00:00
image = "docker.service.consul:5000/ducampsv/docker-backup-postgres:latest"
2022-10-29 08:39:47 +00:00
volumes = [
2024-02-21 18:02:08 +00:00
"/mnt/diskstation/nomad/backup/postgres:/backup"
2022-10-29 08:39:47 +00:00
]
}
template {
data = <<EOH
{{ with secret "secrets/data/database/dump"}}
PGUSER = "dump"
PGPASSWORD = "{{ .Data.data.password }}"
2023-11-01 07:42:04 +00:00
PGHOST = "active.db.service.consul"
2022-10-29 08:39:47 +00:00
{{end}}
EOH
destination = "secrets/secrets.env"
env = true
}
resources {
2024-03-10 08:50:47 +00:00
memory = 180
memory_max = 400
2022-10-29 08:39:47 +00:00
}
}
}
}