WIP: Write a consul backup job
This commit is contained in:
parent
842e656342
commit
a7e276c637
45
nomad/backups/jobs/consul.hcl
Normal file
45
nomad/backups/jobs/consul.hcl
Normal file
@ -0,0 +1,45 @@
|
||||
job "Consul" {
|
||||
schedule = "0 0 * * *"
|
||||
|
||||
config {
|
||||
# TODO: Backup to a meaningful location, this is just for testing
|
||||
repo = "/local/repo"
|
||||
# Read from secret file
|
||||
passphrase = env("BACKUP_PASSPHRASE")
|
||||
}
|
||||
|
||||
# Remove when using a proper backup destination
|
||||
task "Create dir for repo" {
|
||||
pre_script {
|
||||
on_backup = "echo 'Backing up something'"
|
||||
}
|
||||
pre_script {
|
||||
on_backup = "mkdir -p /local/repo"
|
||||
}
|
||||
}
|
||||
|
||||
task "Use consul snapshots" {
|
||||
pre_script {
|
||||
on_backup = "mkdir -p /local/consul"
|
||||
}
|
||||
pre_script {
|
||||
on_backup = "consul snapshot save /local/consul/backup.snap"
|
||||
}
|
||||
post_script {
|
||||
on_restore = "consul snapshot restore /local/consul/backup.snap"
|
||||
}
|
||||
}
|
||||
|
||||
backup {
|
||||
paths = ["/local/consul"]
|
||||
# Because path is absolute
|
||||
restore_opts {
|
||||
Target = "/"
|
||||
}
|
||||
}
|
||||
|
||||
forget {
|
||||
KeepLast = 2
|
||||
Prune = true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user