From c52a5e2d57f122cc7a8572aadc570860e054fc46 Mon Sep 17 00:00:00 2001
From: nd <git@notandy.de>
Date: Thu, 24 Jun 2021 20:52:22 +0200
Subject: [PATCH] add better remote repo support

---
 README.md         | 2 ++
 defaults/main.yml | 9 +++++----
 tasks/main.yml    | 8 ++++----
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 9a29f80..c87d642 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,8 @@ backends:
 		url: '/var/backup-client/restic'
 		# repository type can be 'local' or 'sftp'
 		repo_type: 'local'
+		# additional repo keys to add. Format is "user: key"
+		additional_keys: {}
 
 # Mode in which the backup is taken. One of the following:
 #
diff --git a/defaults/main.yml b/defaults/main.yml
index 4cddbf4..702f71a 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -16,6 +16,7 @@ backups:
     restic:
       url: /var/backup-client/restic
       repo_type: local
+      additional_keys: {}
   mode: vm-via-hypervisor
   enabled: True
   retention:
@@ -36,9 +37,9 @@ backups:
     enabled: False
     create_storage_folder: True
   exclude_files:
-    '/tmp': true
-    '/var/tmp': true
-    '/var/cache': true
-    '/root/.ansible/': true
+    '/tmp/*': true
+    '/var/tmp/*': true
+    '/var/cache/*': true
+    '/root/.ansible/*': true
   include_files:
     '/': true
diff --git a/tasks/main.yml b/tasks/main.yml
index 4c986cc..c23076a 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -154,7 +154,9 @@
         state: "{{ item }}"
 
 - name: handle common restic based setup tasks
-  when: backup_backend == 'restic'
+  when:
+    - backup_backend == 'restic'
+    - backup_executor
   block:
   - name: install backend tools (restic)
     apt:
@@ -202,11 +204,9 @@
       group: root
       mode: 0700
   - name: create repo for restic
-    when: backups.backends.restic.repo_type == 'local'
-    shell: 'source /etc/backup-client/restic.env; restic init'
+    shell: 'source /etc/backup-client/restic.env; restic snapshots > /dev/null || restic init'
     args:
       executable: /bin/bash
-      creates: "{{ backups.backends.restic.url }}/config"
 
 - name: handle hypervisor mode
   when: backups.mode == 'hypervisor-restic'
-- 
GitLab