From d30e30fcaeee34c8f60ac7d1b1fd626d9c815e07 Mon Sep 17 00:00:00 2001 From: L3D Date: Tue, 18 Jan 2022 17:20:02 +0100 Subject: [PATCH] optional cache directory --- README.md | 4 +++- defaults/main.yml | 4 ++++ templates/restic_script_Linux.j2 | 6 ++++-- vars/main.yml | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e697d1..3c7e86f 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ ansible-galaxy install arillso.restic | `restic_version` | `'0.12.1'` | The version of Restic to install | | `restic_download_path` | `'/opt/restic'` | Download location for the restic binary | | `restic_install_path` | `'/usr/local/bin'` | Install location for the restic binary | -| `restic_script_dir` | `'/opt/restic'` | Location of the generated backup scripts | +| `restic_script_dir` | `'/opt/restic'` | Location of the generated backup scripts | | `restic_log_dir` | `'{{ restic_script_dir }}/log'` | Location of the logs of the backup scripts | | `restic_repos` | `{}` | A dictionary of repositories where snapshots are stored. *(More Info: [Repos](#Repos))* | | `restic_backups` | `{}` (or `[]`) | A list of dictionaries specifying the files and directories to be backed up *(More Infos: [Backups](#Backups))* | @@ -79,6 +79,8 @@ ansible-galaxy install arillso.restic | `restic_dir_group` | `'{{ansible_user}}'` | The group of all created dirs | | `restic_no_log` | `true` | set to false to see hidden ansible logs | | `restic_do_not_cleanup_cron ` | `false` | we changed the cron location and clean up the old one. You can skip the cleanup here | +| `restic__cache_config` | `false` | configure custom cache directory | +| `restic__cache_dir` | `'~/.cache/restic'` | define custom cache directory | ### Repos Restic stores data in repositories. You have to specify at least one repository diff --git a/defaults/main.yml b/defaults/main.yml index a9b721f..afaad58 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -24,5 +24,9 @@ restic_systemd_timer_default_OnCalendar: '*-*-* 02:00:00' submodules_versioncheck: false restic_do_not_cleanup_cron: false +# cache +restic__cache_config: false +restic__cache_dir: '~/.cache/restic' + # outdated variables because of irritating names, but kept for compatibility restic_create_cron: false diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index cfd3751..b6a8d6b 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -23,8 +23,6 @@ fi # your normal workflow here... - - {% if item.disable_logging is defined and item.disable_logging %} {% set backup_result_log, backup_output_log = "/dev/null", "/dev/null" %} {% set forget_result_log, forget_output_log = "/dev/null", "/dev/null" %} @@ -38,6 +36,10 @@ fi {% endif %} {% endif %} +{% if restic__cache_config | bool -%} + export XDG_CACHE_HOME={{ restic__cache_dir }} +{% endif %} + export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }} export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'', '\'\\\'\'') }}' BACKUP_NAME={{ item.name }} diff --git a/vars/main.yml b/vars/main.yml index c7e5ec8..2e22da5 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -10,5 +10,5 @@ restic_os_variables: paths: - 'vars' -playbook_version_number: 22 # should be int +playbook_version_number: 23 # should be int playbook_version_path: 'do1jlr.restic.version'