homelab/nomad-job/backup-postgress.nomad

54 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2022-10-29 08:39:47 +00:00
job "backup-postgress" {
datacenters = ["homelab"]
priority = 50
type = "batch"
meta {
forcedeploy = "0"
}
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 {
image = "ducampsv/docker-backup-postgres:latest"
volumes = [
"/mnt/diskstation/git/backup/postgres:/backup"
]
}
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 {
memory = 100
2022-10-29 08:39:47 +00:00
}
}
}
}