From 9ee26955559db3707f06bde600ef88b963366560 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Mon, 16 Oct 2023 16:01:18 +0200
Subject: [PATCH] Customize restic backup settings

---
 docs/30_Configuration/60_File_env.md | 61 +++++++++++++++++++++++++++-
 jobs/env_defaults                    | 16 ++++++++
 plugins/transfer/restic.sh           |  2 +-
 3 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/docs/30_Configuration/60_File_env.md b/docs/30_Configuration/60_File_env.md
index e977c8b..55f7dbf 100644
--- a/docs/30_Configuration/60_File_env.md
+++ b/docs/30_Configuration/60_File_env.md
@@ -3,8 +3,6 @@ Here you can set custom environment variables.
 
 A common usage is extending the variable PATH to execute binaries that are not located in any directory.
 
-WIP: Or you can override used parameters during backup. The parameters for mysqldump are in env_defaults. If you want to change them then put ``LD_MYSQL_DUMP_PARAMS=...`` into env file.
-
 Example:
 
 This might be helpful on MS Windows. If you put the restic binary "somewhere" eg. c:\portable\restic\restic.exe then you can add the path to the env file:
@@ -12,3 +10,62 @@ This might be helpful on MS Windows. If you put the restic binary "somewhere" eg
 ```bash
 PATH=/c/portable/restic/:$PATH
 ```
+
+## Override parameters
+
+In the file ``jobs/env_defaults`` are some vars to set some defaults for the command lines during backup.
+Do not edit this file - it is part of the repository. To customize a value copy it to ``jobs/env`` and make your changes there.
+
+```bash
+#!/bin/bash
+# ----------------------------------------------------------------------
+#
+# DEFAULTS !!! Do not edit this file !!! 
+# Overide customizations in file "env" (maybe copy env.dist to env first)
+#
+# ----------------------------------------------------------------------
+
+# ----------------------------------------------------------------------
+# Localdump
+# ----------------------------------------------------------------------
+
+# mysql
+LD_MYSQL_DUMP_PARAMS="--opt \
+            --default-character-set=utf8 \
+            --flush-logs \
+            --single-transaction \
+            --no-autocommit \
+            "
+
+# ----------------------------------------------------------------------
+# Restic backup
+# ----------------------------------------------------------------------
+
+# compression mode (only available for repository format version 2), one of (auto|off|max) (default: $RESTIC_COMPRESSION) (default auto)
+# export RESTIC_COMPRESSION=auto
+
+# Concurrency for file reads (default: 2)
+# RESTIC_READ_CONCURRENCY=
+
+# Target size for pack files
+export RESTIC_PACK_SIZE=128
+
+# injected in command line for restic backup (not a variable of restic)
+RESTIC_PARAMS=--no-scan
+
+# ----------------------------------------------------------------------
+```
+
+### Localdump :: Mysql
+
+You can override used parameters during backup. The parameters for mysqldump are in env_defaults. If you want to change them then put ``LD_MYSQL_DUMP_PARAMS=...`` into env file.
+
+### Transfer :: Restic
+
+There are some environment variables for tuning
+
+* RESTIC_COMPRESSION
+* RESTIC_READ_CONCURRENCY
+* RESTIC_PACK_SIZE
+
+see <https://restic.readthedocs.io/en/latest/047_tuning_backup_parameters.html>
\ No newline at end of file
diff --git a/jobs/env_defaults b/jobs/env_defaults
index 322878b..e4239e2 100644
--- a/jobs/env_defaults
+++ b/jobs/env_defaults
@@ -18,4 +18,20 @@ LD_MYSQL_DUMP_PARAMS="--opt \
             --no-autocommit \
             "
 
+# ----------------------------------------------------------------------
+# Restic backup
+# ----------------------------------------------------------------------
+
+# compression mode (only available for repository format version 2), one of (auto|off|max) (default: $RESTIC_COMPRESSION) (default auto)
+export RESTIC_COMPRESSION=auto
+
+# Concurrency for file reads (default: 2)
+RESTIC_READ_CONCURRENCY=8
+
+# Target size for pack files
+export RESTIC_PACK_SIZE=128
+
+# injected in command line for restic backup (not a variable of restic)
+RESTIC_PARAMS=--no-scan
+
 # ----------------------------------------------------------------------
\ No newline at end of file
diff --git a/plugins/transfer/restic.sh b/plugins/transfer/restic.sh
index d8bb693..a1a7253 100644
--- a/plugins/transfer/restic.sh
+++ b/plugins/transfer/restic.sh
@@ -245,7 +245,7 @@
     }
 
     function t_backupDirGetCmdBackup(){
-        echo eval restic backup ${ARGS_DEFAULT} ${ARGS_BACKUP} ${mydir}
+        echo eval restic backup ${ARGS_DEFAULT} ${ARGS_BACKUP} ${RESTIC_PARAMS} ${mydir}
     }
 
     # pre backup actions
-- 
GitLab