Skip to content
Snippets Groups Projects
Commit b670b29d authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '7000-corrections' into 'master'

fix for db detection from file and cli restore

See merge request !133
parents dc81c2c4 9f0f9d4d
No related branches found
No related tags found
1 merge request!133fix for db detection from file and cli restore
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# 2022-03-17 ..... WIP: add lines with prefix __DB__ # 2022-03-17 ..... WIP: add lines with prefix __DB__
# 2022-11-04 ah rename hooks # 2022-11-04 ah rename hooks
# 2024-03-14 ah v2.0: use profiles for local and remote databases # 2024-03-14 ah v2.0: use profiles for local and remote databases
# 2024-03-18 ah fix for db detection from file and cli restore
# ====================================================================== # ======================================================================
# --- variables: # --- variables:
...@@ -269,19 +270,20 @@ ...@@ -269,19 +270,20 @@
exit 1 exit 1
;; ;;
1) 1)
echo "INFO: No interaction on a single choice. Using '$_selection'" echo "INFO: No interaction on a single choice. Using"
echo " $_selection"
LASTINPUT="$_selection" LASTINPUT="$_selection"
return 0 return 0
;; ;;
*) *)
echo "$_selection" echo "$_selection"
color.print input "${_prompt} >" color.print input "${_prompt} >"
read -r LASTINPUT read -r LASTINPUT
if [ -z "$LASTINPUT" ]; then if [ -z "$LASTINPUT" ]; then
echo "No input given. Aborting." echo "No input given. Aborting."
exit 1 exit 1
fi fi
;; ;;
esac esac
} }
...@@ -569,8 +571,8 @@ EOH ...@@ -569,8 +571,8 @@ EOH
# if there is a single dump in backup folder: # if there is a single dump in backup folder:
# '-rw-r--r-- 1 root root 481 Mar 13 12:27 ahcrawler__20240313-1227.sql.gz' # '-rw-r--r-- 1 root root 481 Mar 13 12:27 ahcrawler__20240313-1227.sql.gz'
# --> take the last part behind the last space to get a filename # --> take the last part behind the last space to get a filename
grep "[rwxsSt\-]{10,} " <<< "$LASTINPUT" \ echo "$LASTINPUT" | grep -qE "^[rwxsSt\-]{10}" \
&& dbfile="$(rev <<< \'"$LASTINPUT"\' | cut -d ' ' -f 1 | rev)" && dbfile="$(rev <<< \'"$LASTINPUT"\' | cut -d ' ' -f 1 | rev | sed "s#'\$##" )"
echo echo
sTargetDb=$(guessDB ${dbfile}) sTargetDb=$(guessDB ${dbfile})
...@@ -595,9 +597,13 @@ EOH ...@@ -595,9 +597,13 @@ EOH
rc=$rc+1 rc=$rc+1
else else
PROFILENAME="${sDumpfile//${BACKUP_BASEDIR}/}" # We expect a structure: /somedir/whatever/<PROFILENAME>/<database>.gz
PROFILENAME="$( echo $PROFILENAME | sed "s,^/*,," | cut -f 1 -d '/')" dumpDirname=$( dirname "${sDumpfile}" )
PROFILENAME=$( basename "${dumpDirname}" )
echo "INFO: detected profile: $PROFILENAME"
echo ""
if dbdetect.setProfile "${PROFILENAME}"; then if dbdetect.setProfile "${PROFILENAME}"; then
SERVICENAME=$( dbdetect.getType "$PROFILENAME" ) SERVICENAME=$( dbdetect.getType "$PROFILENAME" )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment