From 84c1dbcf4bbb2036b1d4fe1f0312a1f8b49cc704 Mon Sep 17 00:00:00 2001 From: Lilian Roller Date: Mon, 11 Jan 2021 12:32:06 +0100 Subject: [PATCH] implement new restic arhiver option for compact output --- README.md | 3 +++ defaults/main.yml | 3 +++ templates/restic_forget_snapshots.j2 | 20 ++++++++++++++------ vars/main.yml | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 99f6360..3209aa9 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,9 @@ restic_archiver__package: restic_archiver__log_output: true restic_archiver__logrotate: true +# restic default options +restic_archiver__default_opt: ' --compact --quiet ' + # version check for this playbook (true is recomended) submodules_versioncheck: false ``` diff --git a/defaults/main.yml b/defaults/main.yml index 99357fa..6b20e17 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -52,5 +52,8 @@ restic_archiver__logrotate: true restic_archiver__mailsummary: false restic_archiver__mailaddress: false +# restic default options +restic_archiver__default_opt: ' --compact --quiet ' + # version check for this playbook (true is recomended) submodules_versioncheck: false diff --git a/templates/restic_forget_snapshots.j2 b/templates/restic_forget_snapshots.j2 index 63d8f72..02c61c7 100644 --- a/templates/restic_forget_snapshots.j2 +++ b/templates/restic_forget_snapshots.j2 @@ -46,6 +46,14 @@ --prune {% endif %} {%- endmacro %} +{% if restic_archiver__mail_report | default(false) %} + +# collect info about last snapshot for mail report + +restic {{ restic_archiver__default_opt }} stats latest | grep Total + +{% endif %} + {% if restic_archiver__mount_required %} if mountpoint -q {{ restic_archiver__mount_disk }} then @@ -61,9 +69,9 @@ export RESTIC_REPOSITORY="{{ repo['location'] }}" export RESTIC_PASSWORD='{{ repo['password'] | regex_replace('\'', '\'\\\'\'') }}' 2>/dev/null BACKUP_NAME="{{ repo.name }}" -restic forget {{ retention_pattern(repo) }} +restic {{ restic_archiver__default_opt }} forget {{ retention_pattern(repo) }} -restic check +restic {{ restic_archiver__default_opt }} check {% if repo.archive|default(false) %} # ARCHIVE Settings for Server "{{ repo['name'] | string }}" @@ -75,7 +83,7 @@ BACKUP_NAME="{{ repo.name }}_archive" # init repo if it does not exist if ([ -z "$(restic cat config)" ]) 2>/dev/null; then - restic init --copy-chunker-params + restic {{ restic_archiver__default_opt }} init --copy-chunker-params fi {% if restic_archiver__mount_required %} @@ -95,7 +103,7 @@ export RESTIC_REPOSITORY="{{ repo['location'] }}" export RESTIC_PASSWORD='{{ repo['password'] | regex_replace('\'', '\'\\\'\'') }}' 2>/dev/null # transfer snapshots to archive -restic copy +restic {{ restic_archiver__default_opt }} copy {% if repo.archive_cleanup %} @@ -114,10 +122,10 @@ export RESTIC_REPOSITORY="{{ repo['archive_location'] }}" export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}' 2>/dev/null BACKUP_NAME="{{ repo.name }}_archive" -restic forget {{ retention_pattern(repo) }} +restic {{ restic_archiver__default_opt }} forget {{ retention_pattern(repo) }} {% endif %} -restic check +restic {{ restic_archiver__default_opt }} check {% endif %} {% endfor %} diff --git a/vars/main.yml b/vars/main.yml index 1f5de40..3cc4cdc 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 31 # should be over ninethousand +playbook_version_number: 32 # should be over ninethousand playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'