diff --git a/defaults/main.yml b/defaults/main.yml index 285f6e1..8e40d88 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -59,3 +59,6 @@ restic_archiver__default_opt: '' restic_archiver__additional_mail_msg: '' # version check for this playbook (true is recomended) submodules_versioncheck: false + +restic_archiver__cache_config: false +restic_archiver__cache_dir: '~/.cache/restic' diff --git a/templates/restic_forget_snapshots.j2 b/templates/restic_forget_snapshots.j2 index fc06fec..b196346 100644 --- a/templates/restic_forget_snapshots.j2 +++ b/templates/restic_forget_snapshots.j2 @@ -1,6 +1,12 @@ #!/usr/bin/env bash # {{ ansible_managed }} # This file is to cleanup your backup archive and move some snapshots to a external storage. +{% if restic_archiver__cache_config | bool %} + +# define cache directory +export XDG_CACHE_HOME={{ restic_archiver__cache_dir }} +{% endif %} + {% if restic_archiver__mail_report | default(false) %} @@ -74,12 +80,6 @@ START DUING STUFF INSIDE THE RESTIC REPO FOR LOOP { # try -{% 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 @@ -94,6 +94,12 @@ export RESTIC_REPOSITORY="{{ repo['location'] }}" export RESTIC_PASSWORD='{{ repo['password'] | regex_replace('\'', '\'\\\'\'') }}' 2>/dev/null BACKUP_NAME="{{ repo.name }}" +{% 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 %} + + echo "init $BACKUP_NAME" restic {{ restic_archiver__default_opt }} forget {{ retention_pattern(repo) }} diff --git a/vars/main.yml b/vars/main.yml index 44ddfb1..fe582a1 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 41 # should be int +playbook_version_number: 42 # should be int playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'