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).
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:
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