From 2a47da8804952341e0084fe0dae43cf2d7a34440 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Wed, 9 Feb 2022 09:38:43 +0100
Subject: [PATCH] save space: --no-cache and verbose

---
 docs/30_Configuration/30_Filetransfer.md      | 13 +++++++++----
 docs/30_Configuration/50_File_transfer.job.md |  3 ++-
 jobs/transfer.job.dist                        |  3 ++-
 plugins/transfer/restic.sh                    | 14 +++++++++++++-
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/docs/30_Configuration/30_Filetransfer.md b/docs/30_Configuration/30_Filetransfer.md
index 6902206..c0a0386 100644
--- a/docs/30_Configuration/30_Filetransfer.md
+++ b/docs/30_Configuration/30_Filetransfer.md
@@ -114,11 +114,16 @@ If your /root partition has a limited size and/ or you have a lot of files
 
 `restic_cachedir = [full path]`
 
-The default verbose of IML backup for restic is 2. During file transfer
-this shows unchanged/ new/ deleted files. Change it to a less value
-to generate less log data.
+Restic by default stores file indexes locally. To save space in `restic_cachedir`
+you can disable the file index but the backup will run much slower.
 
-`restic_verbose = 2`
+`restic_nochache = false`
+
+The default verbose of IML backup for restic is 0. 
+If you want to see unchanged/ new/ deleted files set it to "2". But This generates
+larger logs in [installdir]/logs/.
+
+`restic_verbose = 0`
 
 A file transfer can be tagged. Each restic backup gets a defined tag
 
diff --git a/docs/30_Configuration/50_File_transfer.job.md b/docs/30_Configuration/50_File_transfer.job.md
index c02b4b2..9ee46da 100644
--- a/docs/30_Configuration/50_File_transfer.job.md
+++ b/docs/30_Configuration/50_File_transfer.job.md
@@ -247,8 +247,9 @@ bin = restic.
 ```text
 # use another cache directory than /root/.cache/restic
 restic_cachedir =  
+restic_nocache = false
 
-restic_verbose = 2
+restic_verbose = 0
 restic_tag = imlbackup
 
 restic_mountpoint = /mnt/restore
diff --git a/jobs/transfer.job.dist b/jobs/transfer.job.dist
index 4e5dfbd..06ee1b9 100644
--- a/jobs/transfer.job.dist
+++ b/jobs/transfer.job.dist
@@ -139,8 +139,9 @@ duplicity_cachedir =
 
 # use another cache directory than /root/.cache/restic
 restic_cachedir =  
+restic_nocache = false
 
-restic_verbose = 2
+restic_verbose = 0
 restic_tag = imlbackup
 
 restic_mountpoint = /mnt/restore
diff --git a/plugins/transfer/restic.sh b/plugins/transfer/restic.sh
index dba32a6..004490f 100644
--- a/plugins/transfer/restic.sh
+++ b/plugins/transfer/restic.sh
@@ -58,8 +58,20 @@
     }
     # return a string with backup parameters that will be added to defaults
     function t_getParamBackup(){
+        local _tag
+        local _nocacheFlag
+
         # tagging
-        echo -n --tag $( _j_getvar ${STORAGEFILE} "${CFGPREFIX}tag" )
+        _tag=$( _j_getvar ${STORAGEFILE} "${CFGPREFIX}tag" )
+        if [ "$_tag" != "" ]; then
+            echo -n "--tag $_tag "
+        fi
+
+        # no cache ... to create smaller local cache dirs, but backup 3 times slower 
+        _nocacheFlag=$( _j_getvar ${STORAGEFILE} "${CFGPREFIX}nocache" )
+        if [ "$_nocacheFlag" != "" ] && [ "$_nocacheFlag" != "0" ] && [ "$_nocacheFlag" != "false" ]; then
+            echo -n "--no-cache "
+        fi
     }
 
     # return a cli parameter for a single exlude directory
-- 
GitLab