diff --git a/defaults/main.yml b/defaults/main.yml index 77ee36e70f56042c426654d523f82182ed5bacc1..f8db1fff11ef6fff18e4870366d07d4a86388095 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,6 +18,8 @@ backups: repo_type: local repo_folder_create: true additional_keys: {} + flags: + - "--cleanup-cache" mode: vm-via-hypervisor enabled: True retention: diff --git a/tasks/main.yml b/tasks/main.yml index 2ac9ec5c9ae62be654a8bca0b4bf9fb00047fa69..f3cfd15ca36453f7b521774fc487e365bb5633b5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,7 +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 %}" + restic_combined_flags: "{{ (backups.backends.restic.flags + (['--no-cache'] if backups.backends.restic.repo_type == 'local' else []))| join(' ') }}" - name: create config folder file: diff --git a/templates/backup-check.j2 b/templates/backup-check.j2 index 67f73bbbd53f7c6606682cc97f3eae4f13bc14d8..843a0c5475f7546d47075a724e0e6d922f920d9d 100755 --- a/templates/backup-check.j2 +++ b/templates/backup-check.j2 @@ -6,7 +6,7 @@ set -euo pipefail source /etc/backup-client/restic.env restic check --read-data \ - --cleanup-cache{% if not backup_restic_cache %} --no-cache{% endif %} + {{ restic_combined_flags }} {% endif %} diff --git a/templates/backup-retention.j2 b/templates/backup-retention.j2 index 3778e51c9d0d6da9bac057b6fb95fa16a8b18ffc..741029d371b093a4dcf9bb3c4ba43443d157470f 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 {% if not backup_restic_cache %} --no-cache{% endif %} \ + {{ restic_combined_flags }} \ --verbose \ --prune \ --group-by "host,paths,tags" \ diff --git a/templates/backup-standalone.j2 b/templates/backup-standalone.j2 index 20d1f438d62609d6b131572057caaf64eb511c27..bd5dd655c48905147570d46ef2b06958e56e85ad 100755 --- a/templates/backup-standalone.j2 +++ b/templates/backup-standalone.j2 @@ -8,7 +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 %} \ + {{ restic_combined_flags }} \ --verbose \ --exclude-caches \ --one-file-system \ diff --git a/templates/backup-vm.j2 b/templates/backup-vm.j2 index 9c6ed3052bbaf7ed8d3edf08b640747cb5647ae6..79438f33cb0c58718b1f46c8f9d97ac4363e9df5 100755 --- a/templates/backup-vm.j2 +++ b/templates/backup-vm.j2 @@ -122,7 +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 %} \ + {{ restic_combined_flags }} \ --verbose \ --host "$DOMAIN" \ --exclude-file "/etc/backup-client/vms/$DOMAIN/exclude_files" \