mpolinowski / nomadic-borg

Hashicorp Nomad to run periodic backups on hosts

Home Page:https://mpolinowski.github.io/docs/DevOps/Hashicorp/2022-11-11-hashicorp-nomad-for-borg-backups/2022-11-11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nomadic BORG

Run periodic backups using Hashicorp Nomad's Periodic Stanza with the BORG Docker container by @pschiffe:

type = "batch"

periodic {
    cron = "@daily"
}

reschedule {
    attempts  = 0
    unlimited = false
}

See backup-service.tf for an example to backup the MariaDB Database data directory of an PHP CMS (OSTicket).

Restore a Backup

A restore can be run manually and then copied to the data directory restoring the old database. To find the correct backup we have to find the short allocation ID for the backup job run:

Hashicorp Nomad to run periodic backups

In the case above it is c0c8ec8d. We have to use the ARCHIVE=c0c8ec8d environment variable accordingly to retrieve your data:

docker run \
  --rm \
  -e BORG_REPO=/opt/borg \
  -e ARCHIVE=c0c8ec8d \
  -e BORG_PASSPHRASE=mypassword \
  -e EXTRACT_TO=/borg/output \
  -v /opt/borg/config:/root \
  -v /opt/borg/repo:/opt/borg \
  -v /opt/borg/output:/borg/output/data \
  --security-opt label:disable \
  --name borg-backup \
  pschiffe/borg

...

terminating with success status, rc 0