From eedd0e15aa7df72a80b738fd6941c39b40490c7d Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 23 Jan 2024 10:41:22 +0100
Subject: [PATCH] add restic_prune-params

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

diff --git a/docs/30_Configuration/50_File_transfer.job.md b/docs/30_Configuration/50_File_transfer.job.md
index 42368f6..4016f6a 100644
--- a/docs/30_Configuration/50_File_transfer.job.md
+++ b/docs/30_Configuration/50_File_transfer.job.md
@@ -163,6 +163,8 @@ restic_keep-weekly = 12
 restic_keep-monthly = 12
 restic_keep-yearly = 10
 
+restic_prune-params = --max-unused unlimited --max-repack-size 1G --cleanup-cache
+
 # ----------------------------------------------------------------------
 ```
 
@@ -279,6 +281,8 @@ restic_keep-within = 6m
 # restic_keep-weekly = 12
 # restic_keep-monthly = 12
 # restic_keep-yearly = 10
+
+restic_prune-params = --max-unused unlimited --max-repack-size 1G --cleanup-cache
 ```
 
 For pruning with restic forget the following values can be used. 
@@ -292,6 +296,9 @@ See the docs for more details to the keep values of the forget command <https://
 * restic_keep-within-(hourly|daily|weekly|monthly|yearly) [duration] - keep snapshots of given period that are newer than duration (eg. 1y5m7d2h) relative to the latest snapshot
 * restic_keep-tag [taglist] - keep snapshots with this taglist (can be specified only one in imlbackup) (default [])
 
+* restic_prune-params [options] - additional prune options. see `restic prune help`
+
+
 ## restore-path
 
 Default path where to put restored file when running *restore.sh*.
diff --git a/jobs/transfer.job.dist b/jobs/transfer.job.dist
index 9c1fa30..bd3fffd 100644
--- a/jobs/transfer.job.dist
+++ b/jobs/transfer.job.dist
@@ -163,4 +163,6 @@ restic_keep-within = 6m
 # restic_keep-monthly = 12
 # restic_keep-yearly = 10
 
+restic_prune-params = --max-unused unlimited --max-repack-size 1G --cleanup-cache
+
 # ----------------------------------------------------------------------
diff --git a/plugins/transfer/restic.sh b/plugins/transfer/restic.sh
index 5aadf38..be5b4d3 100644
--- a/plugins/transfer/restic.sh
+++ b/plugins/transfer/restic.sh
@@ -189,19 +189,19 @@
         local _mycmd="forget \
           --tag $_tag \
           --group-by paths,tags \
-          --prune \
-          --max-unused unlimited \
-          --cleanup-cache"
+          --prune "
 
         local _keep
         for mykeep in last hourly daily weekly monthly yearly within within-hourly within-daily within-weekly within-monthly within-yearly tag
         do
             _keep=$( _j_getvar "${STORAGEFILE}" "${CFGPREFIX}keep-${mykeep}")
             if [ -n "$_keep" ]; then
-                _mycmd="${_mycmd} --keep-${mykeep} ${_keep}"
+                _mycmd+="--keep-${mykeep} ${_keep} "
             fi
         done
 
+        _mycmd+=$( _j_getvar "${STORAGEFILE}" "restic_prune-params")
+
         _restic "$_mycmd"
         _myrc=$?
 
-- 
GitLab