Setup borgDetails and set default value

This commit is contained in:
Asif Bacchus 2018-10-03 17:41:57 -06:00
parent 165327e542
commit b38f6fa11c

View File

@ -134,6 +134,9 @@ err503File="${err503Path##*/}"
# set default sqlDetails path to scriptPath # set default sqlDetails path to scriptPath
sqlDetails="$scriptPath/nc_sql.details" sqlDetails="$scriptPath/nc_sql.details"
# set default borgDetails path to scriptPath
borgDetails=$"scriptPath/nc_borg.details"
# set borg parameters to 'normal' verbosity # set borg parameters to 'normal' verbosity
borgCreateParams='--stats' borgCreateParams='--stats'
borgPruneParams='--list' borgPruneParams='--list'
@ -176,7 +179,7 @@ if [ -n "$1" ] && [[ ! "$1" =~ ^- ]]; then
fi fi
# use GetOpts to process parameters # use GetOpts to process parameters
while getopts ':l:n:u:v5:w:s:' PARAMS; do while getopts ':l:n:u:v5:w:s:b:' PARAMS; do
case "$PARAMS" in case "$PARAMS" in
l) l)
# use provided location for logFile # use provided location for logFile
@ -208,6 +211,10 @@ while getopts ':l:n:u:v5:w:s:' PARAMS; do
# path to file containing SQL login details # path to file containing SQL login details
sqlDetails="${OPTARG%/}" sqlDetails="${OPTARG%/}"
;; ;;
b)
# path to file containing borgbackup settings and details
borgDetails="${OPTARG%/}"
;;
?) ?)
# unrecognized parameters trigger scriptHelp # unrecognized parameters trigger scriptHelp
scriptHelp scriptHelp
@ -268,6 +275,16 @@ if [ "$checkResult" = "1" ]; then
exit 1 exit 1
fi fi
## Ensure borgDetails file exists
checkExist ff "$borgDetails"
checkResult="$?"
if [ "$checkResult" = "1" ]; then
# sqlDetails file cannot be found
echo -e "\n${err}The file containing your borgbackup details does not" \
"exist (-b parameter)${normal}\n"
exit 1
fi
### Log start of script operations ### Log start of script operations
echo -e "\e[1;35m${stamp}-- Start $scriptName execution ---${normal}" \ echo -e "\e[1;35m${stamp}-- Start $scriptName execution ---${normal}" \
@ -380,6 +397,11 @@ else
quit 200; quit 200;
fi fi
### Call borgbackup to copy actual files
echo -e "${op}${stamp} Pre-backup tasks completed, calling borgbackup..."
## Get borgbackup settings and repo details
mapfile -t borgConfig < $borgDetails
### Exit NextCloud maintenance mode ### Exit NextCloud maintenance mode
ncMaint off ncMaint off