From 0f2eacfaf4372862225447dcdb2c32804994490b Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Mon, 18 Mar 2024 16:17:21 +0100
Subject: [PATCH] fix list databases (path with dots cut the name)

---
 localdump.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/localdump.sh b/localdump.sh
index 6eef047..2c4f134 100755
--- a/localdump.sh
+++ b/localdump.sh
@@ -201,16 +201,20 @@
     # global  string  BACKUP_BASEDIR  base directory of all backups of selected dbprofile
     # param  string  optional: DB-Name for file filter to select from existing dumps;
     function listBackupedDBs(){
+        local _filter="$1"
         if [ -d "${BACKUP_TARGETDIR}" ]; then
-            if [ -z $1 ]; then
+            if [ -z "$_filter" ]; then
                 # list all databases
                 find "${BACKUP_TARGETDIR}" -mindepth 1 -maxdepth 1 -type f -exec basename {} \; \
-                    | sed "s#__[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9].*##g" \
-                    | sed "s#\..*##g" \
-                    | sort -ud| sed "s#^\./##g"
+                    | sed -e "s#__[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9].*##g" \
+                          -e "s#\.couchdb\.*##g" \
+                          -e "s#\.gz.meta\$##g" \
+                          -e "s#\.gz\$##g" \
+                    | sort -ud \
+                    | sed "s#^\./##g"
             else
                 # list dumps of a database
-                ls -ltr ${BACKUP_TARGETDIR}/${1}*gz | sed "s,${BACKUP_TARGETDIR}/,,g"
+                ls -ltr ${BACKUP_TARGETDIR}/${_filter}*gz | sed "s,${BACKUP_TARGETDIR}/,,g"
             fi
         else
             color.echo error "ERROR: ${BACKUP_TARGETDIR} does not exist - here are no backups to restore."
@@ -271,7 +275,7 @@
                 ;;
             1) 
                 echo "INFO: No interaction on a single choice. Using"
-                echo "      $_selection"
+                color.echo "cmd" "      $_selection"
                 LASTINPUT="$_selection"
                 return 0
                 ;;
-- 
GitLab