From 97240d044fa08a9635455583b081848925170fcb Mon Sep 17 00:00:00 2001 From: Johan Van de Wauw Date: Wed, 11 Oct 2023 18:10:51 +0200 Subject: [PATCH 1/2] Allow multiple paths as backup source --- templates/restic_script_Linux.j2 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index 7673546..64302b1 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -75,9 +75,12 @@ export B2_ACCOUNT_ID={{ restic_repos[item.repo].b2_account_id }} {% if restic_repos[item.repo].b2_account_key is defined %} export B2_ACCOUNT_KEY={{ restic_repos[item.repo].b2_account_key }} {% endif %} -{% if item.src is defined %} +{% if item.src is defined and item.src is string %} BACKUP_SOURCE={{ item.src }} {% endif %} +{% if item.src is defined and item.src.__class__.__name__ =='list' %} +BACKUP_SOURCE={{ item.src| join(' ') }} +{% endif %} {% if item.lvm is defined %} # Set up functions for LVM. @@ -177,10 +180,10 @@ set -uxo pipefail {% if n is defined %} --stdin-filename {{ n }}{% endif %} {%- endmacro %} {# - Define path + Define paths #} -{% macro path(repo) -%} - {% if repo.src is defined and repo.src != None and (repo.src|length>0) %}{{ repo.src }}{% else %}{{ repo.stdin_filename }}{% endif %} +{% macro paths(repo) -%} +{% if repo.src is defined and repo.src != None and (repo.src is not string) %}{%for path in repo.src %} --path {{ path }}{% endfor %}{%elif repo.src is string %}--path {{repo.src}} {% else %}{{ repo.stdin_filename }}{% endif %} {%- endmacro %} {# Define retention pattern @@ -273,7 +276,7 @@ esac {# Define stdin forget commands #} -{{ restic_install_path }}/restic forget --path {{ path(item) }} {{ retention_pattern(item) }} {% if item.prune is defined and item.prune == true %}--prune{% endif %} {{ forget_output_log }} +{{ restic_install_path }}/restic forget {{ paths(item) }} {{ retention_pattern(item) }} {% if item.prune is defined and item.prune == true %}--prune{% endif %} {{ forget_output_log }} if [[ $? -eq 0 ]] then echo "$(date -u '+%Y-%m-%d %H:%M:%S') OK" {{ forget_result_log }} From 304dc65ae96eb3d020c14aa2be52c33c729932cc Mon Sep 17 00:00:00 2001 From: Johan Van de Wauw Date: Thu, 12 Oct 2023 08:54:36 +0200 Subject: [PATCH 2/2] Make sure stdin keeps working --- templates/restic_script_Linux.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index 64302b1..a140676 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -183,7 +183,7 @@ set -uxo pipefail Define paths #} {% macro paths(repo) -%} -{% if repo.src is defined and repo.src != None and (repo.src is not string) %}{%for path in repo.src %} --path {{ path }}{% endfor %}{%elif repo.src is string %}--path {{repo.src}} {% else %}{{ repo.stdin_filename }}{% endif %} +{% if repo.src is defined and repo.src != None and (repo.src is not string) %}{%for path in repo.src %} --path {{ path }}{% endfor %}{%elif repo.src is string %}--path {{repo.src}} {% else %} --path {{ repo.stdin_filename }}{% endif %} {%- endmacro %} {# Define retention pattern