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

update detector and ini validation in localdump

parent 89a9d1e9
No related branches found
No related tags found
1 merge request!129Db Profiles
...@@ -66,6 +66,8 @@ test ! "${sFilter}" = "." && ( echo -n "Filter enabled: "; color.echo "blue" "${ ...@@ -66,6 +66,8 @@ test ! "${sFilter}" = "." && ( echo -n "Filter enabled: "; color.echo "blue" "${
dbdetect._wd "------" dbdetect._wd "------"
for config in $(dbdetect.getConfigs | grep "${sFilter}"); do for config in $(dbdetect.getConfigs | grep "${sFilter}"); do
dbdetect._wd "----- $config" dbdetect._wd "----- $config"
dbdetect.validate $config
if dbdetect.exists $config; then if dbdetect.exists $config; then
color.print "green" "FOUND"; echo ": $config" color.print "green" "FOUND"; echo ": $config"
if [ "$showInfos" -gt "0" ]; then if [ "$showInfos" -gt "0" ]; then
......
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
DBD_BASEDIR=plugins/localdump/profiles DBD_BASEDIR=plugins/localdump/profiles
declare -A DBD_PARAMS declare -A DBD_PARAMS
DBD_INI=
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -68,6 +70,16 @@ function dbdetect.getProfile(){ ...@@ -68,6 +70,16 @@ function dbdetect.getProfile(){
basename "$1" | cut -d "_" -f 1- | sed "s,\.ini$,," basename "$1" | cut -d "_" -f 1- | sed "s,\.ini$,,"
} }
# check if the requirements for a database match
# param string full path of ini file to check
function dbdetect.validate(){
local _config="${1:-$DBD_INIFILE}"
# show errors in profile ini files
ini.validate "$_config" "$( dirname $0)/includes/dbdetect_validate_profile_ini.sh" 0 && dbdetect._wd "OK: Validation of '$_config' successful"
}
# check if the requirements for a database match # check if the requirements for a database match
# param string full path of ini file to check # param string full path of ini file to check
function dbdetect.exists(){ function dbdetect.exists(){
...@@ -77,8 +89,11 @@ function dbdetect.exists(){ ...@@ -77,8 +89,11 @@ function dbdetect.exists(){
local _found=0 local _found=0
# show errors in profile ini files if [ ! -f "$_config" ]; then
ini.validate "$_config" "$( dirname $0)/includes/dbdetect_validate_profile_ini.sh" && dbdetect._wd "Ini validation OK" dbdetect._wd "ERROR: ini file '$_config' does not exist."
return 1
fi
# set file and inisection we read values from # set file and inisection we read values from
ini.set "$_config" "detect" ini.set "$_config" "detect"
...@@ -183,8 +198,8 @@ function dbdetect.exists(){ ...@@ -183,8 +198,8 @@ function dbdetect.exists(){
# set a profile name # set a profile name
# param string profile name # param string profile name
function dbdetect.setProfile(){ function dbdetect.setProfile(){
PROFILENAME="${1:-$PROFILENAME}" DBD_INIFILE="${DBD_BASEDIR}/${1}.ini"
dbdetect.exists "${DBD_BASEDIR}/${PROFILENAME}.ini" dbdetect.exists "${DBD_BASEDIR}/${1}.ini"
} }
function dbdetect.getParams(){ function dbdetect.getParams(){
......
...@@ -228,7 +228,6 @@ function _j_runHooks(){ ...@@ -228,7 +228,6 @@ function _j_runHooks(){
_j_runHooks "$_hookbase" _j_runHooks "$_hookbase"
fi fi
echo
} }
# ------------------------------------------------------------ # ------------------------------------------------------------
......
...@@ -144,10 +144,10 @@ ...@@ -144,10 +144,10 @@
} }
# ------------------------------------------------------------ # ------------------------------------------------------------
# get a list of existing dumper scripts # get a list of existing database profiles
function get_services(){ function get_database_profiles(){
for config in $(dbdetect.getConfigs); do for config in $(dbdetect.getConfigs); do
if dbdetect.exists $config; then if dbdetect.exists "$config"; then
echo "$( dbdetect.getProfile $config )" echo "$( dbdetect.getProfile $config )"
fi fi
done done
...@@ -334,8 +334,8 @@ ...@@ -334,8 +334,8 @@
echo echo
showhelp showhelp
echo echo
echo "On this machine working profiles (see ${BACKUP_PLUGINDIR}):" echo "Hint: On this machine working profiles:"
get_services | sed "s#^# #g" get_database_profiles | nl
echo echo
exit 1 exit 1
fi fi
...@@ -388,22 +388,24 @@ ...@@ -388,22 +388,24 @@
backup) backup)
if [ "$1" = "ALL" ] || [ -z "$1" ]; then if [ "$1" = "ALL" ] || [ -z "$1" ]; then
services=$(get_services) profiles2run=$(get_database_profiles)
echo AUTO: calling local backup scripts for all known services echo AUTO: calling local backup scripts for all active profiles
echo $services echo "$profiles2run" | nl
echo echo
else else
services=$* profiles2run=$*
fi fi
# ----- GO # ----- GO
# PROFILENAME mysql_localhost_13306 # PROFILENAME mysql_localhost_13306
# SERVICENAME mysql # SERVICENAME mysql
# #
for PROFILENAME in $services for PROFILENAME in $profiles2run
do do
if dbdetect.setProfile "${PROFILENAME}"; then if dbdetect.setProfile "${PROFILENAME}"; then
h2 "START PROFILE [${PROFILENAME}]"
SERVICENAME=$( dbdetect.getType "$PROFILENAME" ) SERVICENAME=$( dbdetect.getType "$PROFILENAME" )
BACKUP_PARAMS=$( dbdetect.getParams ) BACKUP_PARAMS=$( dbdetect.getParams )
...@@ -411,9 +413,7 @@ ...@@ -411,9 +413,7 @@
BACKUP_TARGETDIR=${BACKUP_BASEDIR}/${PROFILENAME} BACKUP_TARGETDIR=${BACKUP_BASEDIR}/${PROFILENAME}
ARCHIVE_DIR=$(_j_getvar "${JOBFILE}" dir-dbarchive)/${PROFILENAME} ARCHIVE_DIR=$(_j_getvar "${JOBFILE}" dir-dbarchive)/${PROFILENAME}
BACKUP_SCRIPT=$( get_service_script ${SERVICENAME} ) BACKUP_SCRIPT=$( get_service_script ${SERVICENAME} )
# ----- start service specific script
h2 "START SCRIPT FOR [${PROFILENAME}] -> ${SERVICENAME}"
# ------ set env # ------ set env
# echo "BACKUP_PARAMS = $BACKUP_PARAMS" # echo "BACKUP_PARAMS = $BACKUP_PARAMS"
...@@ -438,10 +438,16 @@ ...@@ -438,10 +438,16 @@
else else
echo "SKIP: $PROFILENAME" echo "SKIP: profile '$PROFILENAME' "
# see why it is not active
DBD_DEBUG=1; dbdetect.setProfile "${PROFILENAME}"; echo; DBD_DEBUG=0
fi fi
# just to have it in the output
dbdetect.validate
done done
;; ;;
...@@ -475,8 +481,8 @@ ...@@ -475,8 +481,8 @@
if ! dbdetect.setProfile "${parService}"; then if ! dbdetect.setProfile "${parService}"; then
color.echo error "ERROR: profile [${parService}] is not known here (or database service is stopped)." color.echo error "ERROR: profile [${parService}] is not known here (or database service is stopped)."
echo echo
echo "Existing services:" echo "Existing database profiles:"
get_services get_database_profiles
exit 1 exit 1
fi fi
if [ ! -d "${BACKUP_BASEDIR}/${parService}" ]; then if [ ! -d "${BACKUP_BASEDIR}/${parService}" ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment