Skip availability checks by default

This commit is contained in:
Dave Conroy
2022-09-20 12:49:43 -07:00
parent 73ad356ebf
commit 8706d3a91c
2 changed files with 90 additions and 87 deletions

View File

@@ -20,5 +20,6 @@ S3_PROTOCOL=${S3_PROTOCOL:-"https"}
SCRIPT_LOCATION_PRE=${SCRIPT_LOCATION_PRE:-"/assets/scripts/pre/"} SCRIPT_LOCATION_PRE=${SCRIPT_LOCATION_PRE:-"/assets/scripts/pre/"}
SCRIPT_LOCATION_POST=${SCRIPT_LOCATION_POST:-"/assets/scripts/post/"} SCRIPT_LOCATION_POST=${SCRIPT_LOCATION_POST:-"/assets/scripts/post/"}
SIZE_VALUE=${SIZE_VALUE:-"bytes"} SIZE_VALUE=${SIZE_VALUE:-"bytes"}
SKIP_AVAILABILITY_CHECK=${SKIP_AVAILABILITY_CHECK:-"TRUE"}
SPLIT_DB=${SPLIT_DB:-"TRUE"} SPLIT_DB=${SPLIT_DB:-"TRUE"}
TEMP_LOCATION=${TEMP_LOCATION:-"/tmp/backups"} TEMP_LOCATION=${TEMP_LOCATION:-"/tmp/backups"}

View File

@@ -363,101 +363,103 @@ backup_sqlite3() {
check_availability() { check_availability() {
### Set the Database Type ### Set the Database Type
case "$dbtype" in if var_false "${SKIP_AVAILABILITY_CHECK}" ; then
"couch" ) case "$dbtype" in
counter=0 "couch" )
code_received=0 counter=0
while [ "${code_received}" != "200" ]; do code_received=0
code_received=$(curl -XGET -sSL -o /dev/null -L -w ''%{http_code}'' ${DB_HOST}:${DB_PORT}) while [ "${code_received}" != "200" ]; do
if [ "${code_received}" = "200" ] ; then break ; fi code_received=$(curl -XGET -sSL -o /dev/null -L -w ''%{http_code}'' ${DB_HOST}:${DB_PORT})
sleep 5 if [ "${code_received}" = "200" ] ; then break ; fi
(( counter+=5 )) sleep 5
print_warn "CouchDB Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)" (( counter+=5 ))
done print_warn "CouchDB Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)"
;; done
"influx" ) ;;
counter=0 "influx" )
case "${INFLUX_VERSION,,}" in counter=0
1 ) case "${INFLUX_VERSION,,}" in
while ! (nc -z ${DB_HOST#*//} ${DB_PORT}) ; do 1 )
while ! (nc -z ${DB_HOST#*//} ${DB_PORT}) ; do
sleep 5
(( counter+=5 ))
print_warn "InfluxDB Host '${DB_HOST#*//}' is not accessible, retrying.. ($counter seconds so far)"
done
;;
2 )
code_received=0
while [ "${code_received}" != "200" ]; do
code_received=$(curl -XGET -sSL -o /dev/null -w ''%{http_code}'' ${DB_HOST}:${DB_PORT}/health)
if [ "${code_received}" = "200" ] ; then break ; fi
sleep 5
(( counter+=5 ))
print_warn "InfluxDB Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)"
done
;;
esac
;;
"mongo" )
if [ "${MONGO_HOST_TYPE,,}" != "atlas" ] || [ -z "${MONGO_CUSTOM_URI}" ]; then
counter=0
while ! (nc -z ${DB_HOST} ${DB_PORT}) ; do
sleep 5 sleep 5
(( counter+=5 )) (( counter+=5 ))
print_warn "InfluxDB Host '${DB_HOST#*//}' is not accessible, retrying.. ($counter seconds so far)" print_warn "Mongo Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)"
done done
;; fi
2 ) ;;
code_received=0 "mysql" )
while [ "${code_received}" != "200" ]; do counter=0
code_received=$(curl -XGET -sSL -o /dev/null -w ''%{http_code}'' ${DB_HOST}:${DB_PORT}/health) export MYSQL_PWD=${DB_PASS}
if [ "${code_received}" = "200" ] ; then break ; fi while ! (mysqladmin -u"${DB_USER}" -P"${DB_PORT}" -h"${DB_HOST}" status > /dev/null 2>&1) ; do
sleep 5 sleep 5
(( counter+=5 )) (( counter+=5 ))
print_warn "InfluxDB Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)" print_warn "MySQL/MariaDB Server '${DB_HOST}' is not accessible, retrying.. (${counter} seconds so far)"
done done
;; ;;
esac "mssql" )
;;
"mongo" )
if [ "${MONGO_HOST_TYPE,,}" != "atlas" ] || [ -z "${MONGO_CUSTOM_URI}" ]; then
counter=0 counter=0
while ! (nc -z ${DB_HOST} ${DB_PORT}) ; do while ! (nc -z ${DB_HOST} ${DB_PORT}) ; do
sleep 5 sleep 5
(( counter+=5 )) (( counter+=5 ))
print_warn "Mongo Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)" print_warn "MSSQL Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)"
done done
fi ;;
;; "pgsql" )
"mysql" ) counter=0
counter=0 export PGPASSWORD=${DB_PASS}
export MYSQL_PWD=${DB_PASS} until pg_isready --dbname=${DB_NAME} --host=${DB_HOST} --port=${DB_PORT} --username=${DB_USER} -q
while ! (mysqladmin -u"${DB_USER}" -P"${DB_PORT}" -h"${DB_HOST}" status > /dev/null 2>&1) ; do do
sleep 5 sleep 5
(( counter+=5 )) (( counter+=5 ))
print_warn "MySQL/MariaDB Server '${DB_HOST}' is not accessible, retrying.. (${counter} seconds so far)" print_warn "Postgres Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)"
done done
;; ;;
"mssql" ) "redis" )
counter=0 counter=0
while ! (nc -z ${DB_HOST} ${DB_PORT}) ; do while ! (nc -z "${DB_HOST}" "${DB_PORT}") ; do
sleep 5 sleep 5
(( counter+=5 )) (( counter+=5 ))
print_warn "MSSQL Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)" print_warn "Redis Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)"
done done
;; ;;
"pgsql" ) "sqlite3" )
counter=0 if [[ ! -e "${DB_HOST}" ]]; then
export PGPASSWORD=${DB_PASS} print_error "File '${DB_HOST}' does not exist."
until pg_isready --dbname=${DB_NAME} --host=${DB_HOST} --port=${DB_PORT} --username=${DB_USER} -q exit_code=2
do exit $exit_code
sleep 5 elif [[ ! -f "${DB_HOST}" ]]; then
(( counter+=5 )) print_error "File '${DB_HOST}' is not a file."
print_warn "Postgres Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)" exit_code=2
done exit $exit_code
;; elif [[ ! -r "${DB_HOST}" ]]; then
"redis" ) print_error "File '${DB_HOST}' is not readable."
counter=0 exit_code=2
while ! (nc -z "${DB_HOST}" "${DB_PORT}") ; do exit $exit_code
sleep 5 fi
(( counter+=5 )) ;;
print_warn "Redis Host '${DB_HOST}' is not accessible, retrying.. ($counter seconds so far)" esac
done fi
;;
"sqlite3" )
if [[ ! -e "${DB_HOST}" ]]; then
print_error "File '${DB_HOST}' does not exist."
exit_code=2
exit $exit_code
elif [[ ! -f "${DB_HOST}" ]]; then
print_error "File '${DB_HOST}' is not a file."
exit_code=2
exit $exit_code
elif [[ ! -r "${DB_HOST}" ]]; then
print_error "File '${DB_HOST}' is not readable."
exit_code=2
exit $exit_code
fi
;;
esac
} }
check_exit_code() { check_exit_code() {