From 3b69a5b3bba6ebdf05ab908446462c07e54ee91f Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Wed, 13 Mar 2024 16:58:41 +0100
Subject: [PATCH] add check for security file

---
 plugins/localdump/couchdb2.sh | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/plugins/localdump/couchdb2.sh b/plugins/localdump/couchdb2.sh
index 8383466..9119fc5 100755
--- a/plugins/localdump/couchdb2.sh
+++ b/plugins/localdump/couchdb2.sh
@@ -473,12 +473,18 @@ function restoreByFile(){
   h2 add security infos ...
   # todo: this will fail when restoring from "deleted_databases" folder
   SECURITYFILE="${ARCHIVE_DIR}/security/__security__${_sourceDB}.json"
-  SECDATA="$( cat $SECURITYFILE )"
-  color cmd
-  echo "add security data: $SECDATA"
-  _couchapi PUT "${dbname}/_security" "$SECDATA"
-  fetchrc
-  color reset
+  if [ -f "$SECURITYFILE" ]; then
+    SECDATA="$( cat $SECURITYFILE )"
+    color cmd
+    echo "add security data: $SECDATA"
+    _couchapi PUT "${dbname}/_security" "$SECDATA"
+    fetchrc
+    color reset
+  else
+    color warning 
+    echo "WARNING: no security data file was found: $SECURITYFILE"
+    color reset
+  fi
 
   echo
 
-- 
GitLab