Removed normal and verbose logging.
Replaced verbose warnings in 503 section with codes.
This commit is contained in:
parent
5ff7a43870
commit
83442bc6fb
78
backup.sh
78
backup.sh
@ -82,9 +82,6 @@ logFile="$scriptPath/${scriptName%.*}.log"
|
|||||||
|
|
||||||
# set script parameters to null and initialize array variables
|
# set script parameters to null and initialize array variables
|
||||||
unset PARAMS
|
unset PARAMS
|
||||||
unset logLevel
|
|
||||||
unset logFileNormal
|
|
||||||
unset logFileVerbose
|
|
||||||
unset borgCreateParams
|
unset borgCreateParams
|
||||||
unset borgPruneParams
|
unset borgPruneParams
|
||||||
unset sqlDumpDir
|
unset sqlDumpDir
|
||||||
@ -123,12 +120,14 @@ while getopts ':l:nv5:w:' PARAMS; do
|
|||||||
logFile="${OPTARG}"
|
logFile="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
# standard logging (script errors, Borg summary)
|
# normal output from Borg
|
||||||
logLevel="normal"
|
borgCreateParams='--stats'
|
||||||
|
borgPruneParams='--list'
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
# verbose logging (script errors, Borg details)
|
# verbose output from Borg
|
||||||
logLevel="verbose"
|
borgCreateParams='--list --stats'
|
||||||
|
borgPruneParams='--list'
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
# 503 error page location
|
# 503 error page location
|
||||||
@ -152,20 +151,6 @@ if [ $(id -u) -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
### Set logging verbosity based on invocation parameters
|
|
||||||
if [ "$logLevel" = "normal" ]; then
|
|
||||||
borgCreateParams='--stats'
|
|
||||||
borgPruneParams="--list"
|
|
||||||
logFileVerbose="/dev/null"
|
|
||||||
logFileNormal="$logFile"
|
|
||||||
elif [ "$logLevel" = "verbose" ]; then
|
|
||||||
borgCreateParams='--list --stats'
|
|
||||||
borgPruneParams='--list'
|
|
||||||
logFileVerbose="$logFile"
|
|
||||||
logFileNormal="/dev/null"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
### Log start of script operations
|
### Log start of script operations
|
||||||
echo -e "${bold}${stamp}-- Start $scriptName execution ---" >> "$logFile"
|
echo -e "${bold}${stamp}-- Start $scriptName execution ---" >> "$logFile"
|
||||||
|
|
||||||
@ -176,12 +161,9 @@ export logFile="$logFile"
|
|||||||
|
|
||||||
### Create sqlDump temporary directory and sqlDumpFile name
|
### Create sqlDump temporary directory and sqlDumpFile name
|
||||||
sqlDumpDir=$( mktemp -d )
|
sqlDumpDir=$( mktemp -d )
|
||||||
echo -e "${cyan}${stamp} Created temp dir for SQLdump: $sqlDumpDir" \
|
|
||||||
>> "$logFileVerbose"
|
|
||||||
sqlDumpFile="backup-`date +%Y%m%d_%H%M%S`.sql"
|
sqlDumpFile="backup-`date +%Y%m%d_%H%M%S`.sql"
|
||||||
echo -e "${normal}${stamp} mySQL dump file will be stored at:" \
|
echo -e "${normal}${stamp} mySQL dump file will be stored at:" >> "$logFile"
|
||||||
"${bold}${yellow}${sqlDumpDir}/${sqlDumpFile}${normal}" \
|
echo -e "${bold}${yellow}${sqlDumpDir}/${sqlDumpFile}${normal}" >> "$logFile"
|
||||||
| tee -a "$logFileNormal" "$logFileVerbose" > /dev/null
|
|
||||||
|
|
||||||
|
|
||||||
### 503 error page
|
### 503 error page
|
||||||
@ -189,32 +171,28 @@ echo -e "${normal}${stamp} mySQL dump file will be stored at:" \
|
|||||||
# Verify 503 existance
|
# Verify 503 existance
|
||||||
if [ -z "$location503" ]; then
|
if [ -z "$location503" ]; then
|
||||||
# no 503 file has been provided
|
# no 503 file has been provided
|
||||||
echo -e "${bold}${yellow}${stamp} -- [WARNING] ${warningExplain[5031]}" \
|
echo -e "${bold}${yellow}${stamp} -- [WARNING] code 5031 --${normal}" \
|
||||||
"--${normal}" >> "$logFile"
|
>> "$logFile"
|
||||||
echo -e "$warn503" | tee -a "$logFileNormal" "$logFileVerbose" > /dev/null
|
echo -e "$warn503" >> "$logFile"
|
||||||
exitWarn+=('5031')
|
exitWarn+=('5031')
|
||||||
else
|
else
|
||||||
checkExist ff "$location503"
|
checkExist ff "$location503"
|
||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = "1" ]; then
|
if [ "$checkResult" = "1" ]; then
|
||||||
# 503 file specified could not be found
|
# 503 file specified could not be found
|
||||||
echo -e "${bold}${yellow}${stamp} -- [WARNING]" \
|
echo -e "${bold}${yellow}${stamp} -- [WARNING] code 5032 --${normal}" \
|
||||||
"${warningExplain[5032]} --${normal}" >> "$logFile"
|
>> "$logFile"
|
||||||
echo -e "$warn503" | tee -a "$logFileNormal" "$logFileVerbose" \
|
echo -e "$warn503" >> "$logFile"
|
||||||
> /dev/null
|
|
||||||
exitWarn+=('5032')
|
exitWarn+=('5032')
|
||||||
else
|
else
|
||||||
# 503 file found
|
# 503 file found
|
||||||
echo -e "${bold}${stamp}Found: ${yellow}${location503}${normal}" \
|
|
||||||
>> "$logFileVerbose"
|
|
||||||
|
|
||||||
# verify webroot exists
|
# verify webroot exists
|
||||||
if [ -z "$webroot" ]; then
|
if [ -z "$webroot" ]; then
|
||||||
# no webroot path provided
|
# no webroot path provided
|
||||||
echo -e "${bold}${yellow}${stamp} -- [WARNING]" \
|
echo -e "${bold}${yellow}${stamp} -- [WARNING] code 5033 --"\
|
||||||
"${warningExplain[5033]} --${normal}" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
echo -e "$warn503" | tee -a "$logFileNormal" "$logFileVerbose" \
|
echo -e "$warn503" >> "$logFile"
|
||||||
> /dev/null
|
|
||||||
exitWarn+=('5033')
|
exitWarn+=('5033')
|
||||||
else
|
else
|
||||||
# verify provided webroot path exists
|
# verify provided webroot path exists
|
||||||
@ -222,29 +200,21 @@ else
|
|||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = "1" ]; then
|
if [ "$checkResult" = "1" ]; then
|
||||||
# webroot directory specified could not be found
|
# webroot directory specified could not be found
|
||||||
echo -e "${bold}${yellow}${stamp} -- [WARNING]" \
|
echo -e "${bold}${yellow}${stamp} -- [WARNING] code 5034 --" \
|
||||||
"${warningExplain[5034]} --${normal}" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
echo -e "$warn503" | tee -a "$logFileNormal" "$logFileVerbose" \
|
echo -e "$warn503" "$logFile"
|
||||||
> /dev/null
|
|
||||||
exitWarn+=('5034')
|
exitWarn+=('5034')
|
||||||
else
|
else
|
||||||
# webroot exists and 503 exists, copy 503 to webroot
|
# webroot exists and 503 exists, copy 503 to webroot
|
||||||
echo -e "${bold}${cyan}${stamp} Copying 503 error page to" \
|
|
||||||
"webroot...${normal}" >> "$logFileVerbose"
|
|
||||||
cp "${location503}" "$webroot/" >> "$logFileVerbose" 2>&1
|
cp "${location503}" "$webroot/" >> "$logFileVerbose" 2>&1
|
||||||
copyResult="$?"
|
copyResult="$?"
|
||||||
# verify copy was successful
|
# verify copy was successful
|
||||||
if [ "$copyResult" = "1" ]; then
|
if [ "$copyResult" = "1" ]; then
|
||||||
echo -e "${bold}${yellow}${stamp} -- [WARNING]" \
|
echo -e "${bold}${yellow}${stamp} -- [WARNING] code" \
|
||||||
"${warningExplain[5035]} --${normal}" >> "$logFile"
|
"5035 --${normal}" >> "$logFile"
|
||||||
echo -e "$warn503" | tee -a "$logFileNormal" \
|
echo -e "$warn503" >> "$logFile"
|
||||||
"$logFileVerbose" > /dev/null
|
|
||||||
exitWarn+=('5035')
|
exitWarn+=('5035')
|
||||||
else
|
fi # copy was successful
|
||||||
# copy was successful
|
|
||||||
echo -e "${bold}${cyan}${stamp} ...done" \
|
|
||||||
>> "$logFileVerbose"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user