diff --git a/tasks/main.yml b/tasks/main.yml index 855e4ad..4feb18e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,6 +2,7 @@ set_fact: backup_backend: "{% if backups.mode in ['standalone-restic', 'hypervisor-restic'] %}restic{% else %}False{% endif %}" backup_executor: "{% if backups.mode in ['vm-via-hypervisor'] %}False{% else %}True{% endif %}" + backup_restic_cache: "{% if backups.backends.restic.repo_type == 'local' %}False{% else %}True{% endif %}" - name: create config folder file: diff --git a/templates/backup-check.j2 b/templates/backup-check.j2 index 7f4a0bf..67f73bb 100755 --- a/templates/backup-check.j2 +++ b/templates/backup-check.j2 @@ -5,7 +5,8 @@ set -euo pipefail # restic backend source /etc/backup-client/restic.env -restic check --read-data --cleanup-cache +restic check --read-data \ + --cleanup-cache{% if not backup_restic_cache %} --no-cache{% endif %} {% endif %} diff --git a/templates/backup-retention.j2 b/templates/backup-retention.j2 index 478631d..3778e51 100755 --- a/templates/backup-retention.j2 +++ b/templates/backup-retention.j2 @@ -7,7 +7,7 @@ source /etc/backup-client/retention.env # restic backend source /etc/backup-client/restic.env restic forget \ - --cleanup-cache \ + --cleanup-cache {% if not backup_restic_cache %} --no-cache{% endif %} \ --verbose \ --prune \ --group-by "host,paths,tags" \ diff --git a/templates/backup-standalone.j2 b/templates/backup-standalone.j2 index fd1360e..20d1f43 100755 --- a/templates/backup-standalone.j2 +++ b/templates/backup-standalone.j2 @@ -8,6 +8,7 @@ test -f "/etc/backup-client/enabled" || { echo "Standalone backup is disabled"; source /etc/backup-client/restic.env restic backup \ + --cleanup-cache {% if not backup_restic_cache %} --no-cache{% endif %} \ --verbose \ --exclude-caches \ --one-file-system \ diff --git a/templates/backup-vm.j2 b/templates/backup-vm.j2 index a4575b5..9c6ed30 100755 --- a/templates/backup-vm.j2 +++ b/templates/backup-vm.j2 @@ -122,6 +122,7 @@ set -euo pipefail # restic backend source /etc/backup-client/restic.env restic backup \ + --cleanup-cache {% if not backup_restic_cache %} --no-cache{% endif %} \ --verbose \ --host "$DOMAIN" \ --exclude-file "/etc/backup-client/vms/$DOMAIN/exclude_files" \