feature(BACKUP): allow non-default borg location

- parameter to specify non-default borg program location

Closes github #10
This commit is contained in:
Asif Bacchus 2021-03-08 00:36:32 -07:00
parent 5ea25529b9
commit 4aae61f97e

View File

@ -153,6 +153,10 @@ scriptHelp() {
newline newline
textblock "${magenta}--- script related parameters ---${norm}" textblock "${magenta}--- script related parameters ---${norm}"
newline newline
switchTextblock "-b | --borg"
textblock "FULL path to borg executable file if not in the default location."
defaultsTextblock "(/usr/bin/borg)"
newline
switchTextblock "-c | --config | --details" switchTextblock "-c | --config | --details"
textblock "Path to the configuration key/value-pair file for this script." textblock "Path to the configuration key/value-pair file for this script."
defaultsTextblock "(scriptPath/scriptName.details)" defaultsTextblock "(scriptPath/scriptName.details)"
@ -262,6 +266,7 @@ configDetails="$scriptPath/${scriptName%.*}.details"
err503Copied=0 err503Copied=0
sqlDumpDirCreated=0 sqlDumpDirCreated=0
exclusions=0 exclusions=0
borgPath="/usr/bin/borg"
# borg output verbosity -- normal # borg output verbosity -- normal
borgCreateParams='--stats' borgCreateParams='--stats'
borgPruneParams='--list' borgPruneParams='--list'
@ -300,6 +305,15 @@ while [ $# -gt 0 ]; do
# do NOT colourize log file # do NOT colourize log file
colourizeLogFile=0 colourizeLogFile=0
;; ;;
-b|--borg)
# specify non-default borg path
if [ -n "$2" ]; then
borgPath="${2%/}"
shift
else
badParam empty "$@"
fi
;;
-c|--config|--details) -c|--config|--details)
# location of config details file # location of config details file
if [ -n "$2" ]; then if [ -n "$2" ]; then
@ -421,8 +435,8 @@ if [ ! -f "$configDetails" ]; then
badParam dne "(--details default)" "$configDetails" badParam dne "(--details default)" "$configDetails"
fi fi
# is borg installed? # is borg installed?
if ! command -v borg > /dev/null; then if ! find "$borgPath" -type f -executable > /dev/null 2>&1; then
printf "\n%sERROR: BORG is not installed on this system!%s\n\n" "$err" "$norm" printf "\n%sERROR: BORG cannot be found in the specified or default location on this system!%s\n\n" "$err" "$norm"
exit 3 exit 3
fi fi
# if 503 functionality is enabled, do 503 related files exist? # if 503 functionality is enabled, do 503 related files exist?
@ -719,7 +733,7 @@ printf "%s[%s] -- [INFO] Pre-backup tasks completed, calling borgbackup --%s\n"
## construct the proper borg commandline ## construct the proper borg commandline
# base command # base command
if [ "$exclusions" -eq 0 ]; then if [ "$exclusions" -eq 0 ]; then
borgCMD="borg create --show-rc ${borgCreateParams} \ borgCMD="${borgPath} create --show-rc ${borgCreateParams} \
::$(date +%Y-%m-%d_%H%M%S) \ ::$(date +%Y-%m-%d_%H%M%S) \
${mcConfig%/*} \ ${mcConfig%/*} \
${sqlDumpDir} \ ${sqlDumpDir} \
@ -730,7 +744,7 @@ if [ "$exclusions" -eq 0 ]; then
${dockerVolumeCrypt} \ ${dockerVolumeCrypt} \
${xtraList}" ${xtraList}"
elif [ "$exclusions" -eq 1 ]; then elif [ "$exclusions" -eq 1 ]; then
borgCMD="borg create --show-rc ${borgCreateParams} \ borgCMD="${borgPath} create --show-rc ${borgCreateParams} \
--exclude-from ${borgExcludeListPath} \ --exclude-from ${borgExcludeListPath} \
::$(date +%Y-%m-%d_%H%M%S) \ ::$(date +%Y-%m-%d_%H%M%S) \
${mcConfig%/*} \ ${mcConfig%/*} \
@ -774,7 +788,7 @@ fi
if [ -n "${borgPruneSettings}" ]; then if [ -n "${borgPruneSettings}" ]; then
printf "%s[%s] -- [INFO] Executing borg prune operation --%s\n" \ printf "%s[%s] -- [INFO] Executing borg prune operation --%s\n" \
"$cyan" "$(stamp)" "$norm" >> "$logFile" "$cyan" "$(stamp)" "$norm" >> "$logFile"
borg prune --show-rc -v ${borgPruneParams} ${borgPruneSettings} \ "${borgPath}" prune --show-rc -v ${borgPruneParams} ${borgPruneSettings} \
2>> "$logFile" 2>> "$logFile"
borgPruneResult="$?" borgPruneResult="$?"
else else