From cb2be37c463bd745b0e4ec3b956ce5dff1a3d546 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <remi@le-filament.com>
Date: Tue, 3 Aug 2021 12:27:33 +0200
Subject: [PATCH] [IMP] add cache and update hostname

---
 templates/backup.yaml.j2  | 5 ++++-
 templates/backup2.yaml.j2 | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/templates/backup.yaml.j2 b/templates/backup.yaml.j2
index 6a29844..b48beb5 100644
--- a/templates/backup.yaml.j2
+++ b/templates/backup.yaml.j2
@@ -2,7 +2,7 @@ version: "2.1"
 services:
     backup_privatebin:
         image: tecnativa/duplicity:postgres
-        hostname: backup-privatebin
+        hostname: {{ inventory_hostname_short | lower | regex_replace('_','') }}-privatebin
         environment:
             DST: "swift://privatebin_{{ inventory_hostname|lower }}"
             PGDATABASE: "none"
@@ -20,11 +20,14 @@ services:
             JOB_300_WHAT: "backup --full-if-older-than 6D"
             JOB_302_WHAT: "dup remove-all-but-n-full 5 --force $$DST $$@"
             JOB_302_WHEN: "daily"
+            OPTIONS: "--allow-source-mismatch"
         volumes:
+            - privatebin_backup_cache:/root/.cache/duplicity/
             - privatebin_data:/mnt/backup/src/privatebin:z
         command:
             - /etc/periodic/daily/jobrunner
 
 volumes:
+    privatebin_backup_cache:
     privatebin_data:
         external: true
diff --git a/templates/backup2.yaml.j2 b/templates/backup2.yaml.j2
index 2039764..82ca5ae 100644
--- a/templates/backup2.yaml.j2
+++ b/templates/backup2.yaml.j2
@@ -2,7 +2,7 @@ version: "2.1"
 services:
     backup_privatebin:
         image: tecnativa/duplicity:postgres
-        hostname: backup-privatebin
+        hostname: {{ inventory_hostname_short | lower | regex_replace('_','') }}-privatebin
         environment:
             DST: "swift://privatebin_{{ inventory_hostname|lower }}"
             PGDATABASE: "none"
@@ -20,11 +20,14 @@ services:
             JOB_300_WHAT: "backup --full-if-older-than 6D"
             JOB_302_WHAT: "dup remove-all-but-n-full 5 --force $$DST $$@"
             JOB_302_WHEN: "daily"
+            OPTIONS: "--allow-source-mismatch"
         volumes:
+            - privatebin_backup2_cache:/root/.cache/duplicity/
             - privatebin_data:/mnt/backup/src/privatebin:z
         command:
             - /etc/periodic/daily/jobrunner
 
 volumes:
+    privatebin_backup2_cache:
     privatebin_data:
         external: true
-- 
GitLab