Skip to content
Snippets Groups Projects

fix for db detection from file and cli restore

Merged Hahn Axel (hahn) requested to merge 7000-corrections into master
1 file
+ 20
14
Compare changes
  • Side-by-side
  • Inline
+ 20
14
@@ -17,6 +17,7 @@
# 2022-03-17 ..... WIP: add lines with prefix __DB__
# 2022-11-04 ah rename hooks
# 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:
@@ -269,19 +270,20 @@
exit 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"
return 0
;;
*)
echo "$_selection"
color.print input "${_prompt} >"
read -r LASTINPUT
if [ -z "$LASTINPUT" ]; then
echo "No input given. Aborting."
exit 1
fi
;;
echo "$_selection"
color.print input "${_prompt} >"
read -r LASTINPUT
if [ -z "$LASTINPUT" ]; then
echo "No input given. Aborting."
exit 1
fi
;;
esac
}
@@ -569,8 +571,8 @@ EOH
# 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'
# --> take the last part behind the last space to get a filename
grep "[rwxsSt\-]{10,} " <<< "$LASTINPUT" \
&& dbfile="$(rev <<< \'"$LASTINPUT"\' | cut -d ' ' -f 1 | rev)"
echo "$LASTINPUT" | grep -qE "^[rwxsSt\-]{10}" \
&& dbfile="$(rev <<< \'"$LASTINPUT"\' | cut -d ' ' -f 1 | rev | sed "s#'\$##" )"
echo
sTargetDb=$(guessDB ${dbfile})
@@ -595,9 +597,13 @@ EOH
rc=$rc+1
else
PROFILENAME="${sDumpfile//${BACKUP_BASEDIR}/}"
PROFILENAME="$( echo $PROFILENAME | sed "s,^/*,," | cut -f 1 -d '/')"
# We expect a structure: /somedir/whatever/<PROFILENAME>/<database>.gz
dumpDirname=$( dirname "${sDumpfile}" )
PROFILENAME=$( basename "${dumpDirname}" )
echo "INFO: detected profile: $PROFILENAME"
echo ""
if dbdetect.setProfile "${PROFILENAME}"; then
SERVICENAME=$( dbdetect.getType "$PROFILENAME" )
Loading