diff --git a/detector.sh b/detector.sh index f789b4fbf7189cd2165081a9d487754ca6280e54..a5e028b324ab869f1a40c8c724a001189ca91c5a 100755 --- a/detector.sh +++ b/detector.sh @@ -66,6 +66,8 @@ test ! "${sFilter}" = "." && ( echo -n "Filter enabled: "; color.echo "blue" "${ dbdetect._wd "------" for config in $(dbdetect.getConfigs | grep "${sFilter}"); do dbdetect._wd "----- $config" + dbdetect.validate $config + if dbdetect.exists $config; then color.print "green" "FOUND"; echo ": $config" if [ "$showInfos" -gt "0" ]; then diff --git a/includes/dbdetect.class.sh b/includes/dbdetect.class.sh index 87ed5c917453efeeaf00d12fd9c1d089504f3592..227098f94403795a4b6bf14b33a9c85efdcf3eb7 100644 --- a/includes/dbdetect.class.sh +++ b/includes/dbdetect.class.sh @@ -18,7 +18,9 @@ # ---------------------------------------------------------------------- DBD_BASEDIR=plugins/localdump/profiles + declare -A DBD_PARAMS +DBD_INI= # ---------------------------------------------------------------------- @@ -68,6 +70,16 @@ function dbdetect.getProfile(){ 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 # param string full path of ini file to check function dbdetect.exists(){ @@ -77,8 +89,11 @@ function dbdetect.exists(){ local _found=0 - # show errors in profile ini files - ini.validate "$_config" "$( dirname $0)/includes/dbdetect_validate_profile_ini.sh" && dbdetect._wd "Ini validation OK" + if [ ! -f "$_config" ]; then + dbdetect._wd "ERROR: ini file '$_config' does not exist." + return 1 + fi + # set file and inisection we read values from ini.set "$_config" "detect" @@ -183,8 +198,8 @@ function dbdetect.exists(){ # set a profile name # param string profile name function dbdetect.setProfile(){ - PROFILENAME="${1:-$PROFILENAME}" - dbdetect.exists "${DBD_BASEDIR}/${PROFILENAME}.ini" + DBD_INIFILE="${DBD_BASEDIR}/${1}.ini" + dbdetect.exists "${DBD_BASEDIR}/${1}.ini" } function dbdetect.getParams(){ diff --git a/includes/jobhelper.sh b/includes/jobhelper.sh index 8eb304e8e52f0d61b061bf1ab9304829b65efdbe..353e74139a06e9ae2fa1e958b5060f4c98e4c195 100755 --- a/includes/jobhelper.sh +++ b/includes/jobhelper.sh @@ -228,7 +228,6 @@ function _j_runHooks(){ _j_runHooks "$_hookbase" fi - echo } # ------------------------------------------------------------ diff --git a/localdump.sh b/localdump.sh index 20683f5e05969e378fbee6a663ea8538f09e87b5..85c58786ef8eb389e7518fc6e813a4c30051422b 100755 --- a/localdump.sh +++ b/localdump.sh @@ -144,10 +144,10 @@ } # ------------------------------------------------------------ - # get a list of existing dumper scripts - function get_services(){ + # get a list of existing database profiles + function get_database_profiles(){ for config in $(dbdetect.getConfigs); do - if dbdetect.exists $config; then + if dbdetect.exists "$config"; then echo "$( dbdetect.getProfile $config )" fi done @@ -334,8 +334,8 @@ echo showhelp echo - echo "On this machine working profiles (see ${BACKUP_PLUGINDIR}):" - get_services | sed "s#^# #g" + echo "Hint: On this machine working profiles:" + get_database_profiles | nl echo exit 1 fi @@ -388,22 +388,24 @@ backup) if [ "$1" = "ALL" ] || [ -z "$1" ]; then - services=$(get_services) - echo AUTO: calling local backup scripts for all known services - echo $services + profiles2run=$(get_database_profiles) + echo AUTO: calling local backup scripts for all active profiles + echo "$profiles2run" | nl echo else - services=$* + profiles2run=$* fi # ----- GO # PROFILENAME mysql_localhost_13306 # SERVICENAME mysql # - for PROFILENAME in $services + for PROFILENAME in $profiles2run do + if dbdetect.setProfile "${PROFILENAME}"; then + h2 "START PROFILE [${PROFILENAME}]" SERVICENAME=$( dbdetect.getType "$PROFILENAME" ) BACKUP_PARAMS=$( dbdetect.getParams ) @@ -411,9 +413,7 @@ BACKUP_TARGETDIR=${BACKUP_BASEDIR}/${PROFILENAME} ARCHIVE_DIR=$(_j_getvar "${JOBFILE}" dir-dbarchive)/${PROFILENAME} BACKUP_SCRIPT=$( get_service_script ${SERVICENAME} ) - - # ----- start service specific script - h2 "START SCRIPT FOR [${PROFILENAME}] -> ${SERVICENAME}" + # ------ set env # echo "BACKUP_PARAMS = $BACKUP_PARAMS" @@ -438,10 +438,16 @@ 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 + # just to have it in the output + dbdetect.validate + done ;; @@ -475,8 +481,8 @@ if ! dbdetect.setProfile "${parService}"; then color.echo error "ERROR: profile [${parService}] is not known here (or database service is stopped)." echo - echo "Existing services:" - get_services + echo "Existing database profiles:" + get_database_profiles exit 1 fi if [ ! -d "${BACKUP_BASEDIR}/${parService}" ]; then