From 84b26f347d5425fcb401a54c57c9fa034796c3f4 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 27 Jan 2022 16:56:02 +0100 Subject: [PATCH] Add consul backup with restic --- app/backup/deploy/backup-daily.hcl | 20 +++++++++++-------- .../backup/consul/backup_aws_access_key_id | 1 + .../consul/backup_aws_secret_access_key | 1 + .../backup/consul/backup_restic_password | 1 + .../backup/consul/backup_restic_repository | 1 + op_guide/backup_minio/README.md | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 app/backup/secrets/backup/consul/backup_aws_access_key_id create mode 100644 app/backup/secrets/backup/consul/backup_aws_secret_access_key create mode 100644 app/backup/secrets/backup/consul/backup_restic_password create mode 100644 app/backup/secrets/backup/consul/backup_restic_repository diff --git a/app/backup/deploy/backup-daily.hcl b/app/backup/deploy/backup-daily.hcl index ef9b219..f95882f 100644 --- a/app/backup/deploy/backup-daily.hcl +++ b/app/backup/deploy/backup-daily.hcl @@ -101,7 +101,7 @@ EOH } group "backup-consul" { - task "export-kv-store" { + task "consul-kv-export" { driver = "docker" lifecycle { @@ -111,11 +111,15 @@ EOH config { image = "consul:1.11.2" + network_mode = "host" entrypoint = [ "/bin/sh", "-c" ] - NETWORK MODE HOST args = [ "/bin/consul kv export > $NOMAD_ALLOC_DIR/consul.json" ] } + env { + CONSUL_HTTP_ADDR = "http://consul.service.2.cluster.deuxfleurs.fr:8500" + } + resources { cpu = 200 memory = 200 @@ -129,22 +133,22 @@ EOH } } - task "upload-kv-store" { + task "restic-backup" { driver = "docker" config { image = "restic/restic:0.12.1" entrypoint = [ "/bin/sh", "-c" ] - args = [ "restic backup $NOMAD_ALLOC_DIR && restic forget --keep-within 1m1d --keep-within-weekly 3m --keep-within-monthly 1y ; restic prune --max-unused 50% --max-repack-size 2G ; restic check" ] + args = [ "restic backup $NOMAD_ALLOC_DIR/consul.json && restic forget --keep-within 1m1d --keep-within-weekly 3m --keep-within-monthly 1y ; restic prune --max-unused 50% --max-repack-size 2G ; restic check" ] } template { data = <