diff --git a/backup.sh b/backup.sh index b1f54e6..3b5b0ac 100755 --- a/backup.sh +++ b/backup.sh @@ -134,6 +134,9 @@ err503File="${err503Path##*/}" # set default sqlDetails path to scriptPath sqlDetails="$scriptPath/nc_sql.details" +# set default borgDetails path to scriptPath +borgDetails=$"scriptPath/nc_borg.details" + # set borg parameters to 'normal' verbosity borgCreateParams='--stats' borgPruneParams='--list' @@ -176,7 +179,7 @@ if [ -n "$1" ] && [[ ! "$1" =~ ^- ]]; then fi # 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 l) # 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 sqlDetails="${OPTARG%/}" ;; + b) + # path to file containing borgbackup settings and details + borgDetails="${OPTARG%/}" + ;; ?) # unrecognized parameters trigger scriptHelp scriptHelp @@ -268,6 +275,16 @@ if [ "$checkResult" = "1" ]; then exit 1 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 echo -e "\e[1;35m${stamp}-- Start $scriptName execution ---${normal}" \ @@ -380,6 +397,11 @@ else quit 200; 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 ncMaint off