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
Branches
No related tags found
1 merge request!129Db Profiles
......@@ -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
......
......@@ -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(){
......
......@@ -228,7 +228,6 @@ function _j_runHooks(){
_j_runHooks "$_hookbase"
fi
echo
}
# ------------------------------------------------------------
......
......@@ -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 )
......@@ -412,8 +414,6 @@
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment