Compare commits
No commits in common. "0718413d79bf6db8e92a5a95b60afcd04153b31c" and "035c7cfabb7c42a1795b1ae6c79211b1484e97b5" have entirely different histories.
0718413d79
...
035c7cfabb
@ -147,7 +147,7 @@ function checkExist {
|
|||||||
|
|
||||||
### ncMaint - pass requested mode change type to NextCloud occ
|
### ncMaint - pass requested mode change type to NextCloud occ
|
||||||
function ncMaint {
|
function ncMaint {
|
||||||
sudo -u ${webUser} php ${ncRoot}/occ maintenance:mode --$1 \
|
sudo -u ${webUser} php ${ncroot}/occ maintenance:mode --$1 \
|
||||||
>> "$logFile" 2>&1
|
>> "$logFile" 2>&1
|
||||||
maintResult="$?"
|
maintResult="$?"
|
||||||
return "$maintResult"
|
return "$maintResult"
|
||||||
@ -162,7 +162,7 @@ function cleanup {
|
|||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = "0" ]; then
|
if [ "$checkResult" = "0" ]; then
|
||||||
# directory still exists
|
# directory still exists
|
||||||
exitWarn+=("${stamp}_111")
|
exitWarn+=('111')
|
||||||
else
|
else
|
||||||
# directory removed
|
# directory removed
|
||||||
echo -e "${op}${stamp} Removed SQL temp directory${normal}" \
|
echo -e "${op}${stamp} Removed SQL temp directory${normal}" \
|
||||||
@ -180,7 +180,7 @@ function cleanup {
|
|||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = "0" ]; then
|
if [ "$checkResult" = "0" ]; then
|
||||||
# file still exists
|
# file still exists
|
||||||
exitWarn+=("${stamp}_5030")
|
exitWarn+=('5030')
|
||||||
else
|
else
|
||||||
# file removed
|
# file removed
|
||||||
echo -e "${info}${stamp} -- [INFO] 503 page removed from webroot" \
|
echo -e "${info}${stamp} -- [INFO] 503 page removed from webroot" \
|
||||||
@ -198,7 +198,7 @@ function cleanup {
|
|||||||
echo -e "${info}${stamp} -- [INFO] NextCloud now in regular" \
|
echo -e "${info}${stamp} -- [INFO] NextCloud now in regular" \
|
||||||
"operating mode --${normal}" >> "$logFile"
|
"operating mode --${normal}" >> "$logFile"
|
||||||
else
|
else
|
||||||
exitError+=("${stamp}_101")
|
exitError+=('101')
|
||||||
quit
|
quit
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ while getopts ':l:n:u:v5:w:s:b:d:' PARAMS; do
|
|||||||
case "$PARAMS" in
|
case "$PARAMS" in
|
||||||
l)
|
l)
|
||||||
# use provided location for logFile
|
# use provided location for logFile
|
||||||
logFile="${OPTARG%/}"
|
logFile="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
# NextCloud webroot
|
# NextCloud webroot
|
||||||
@ -348,7 +348,7 @@ done
|
|||||||
## If not running as root, display error on console and exit
|
## If not running as root, display error on console and exit
|
||||||
if [ $(id -u) -ne 0 ]; then
|
if [ $(id -u) -ne 0 ]; then
|
||||||
echo -e "\n${err}This script MUST be run as ROOT. Exiting.${normal}"
|
echo -e "\n${err}This script MUST be run as ROOT. Exiting.${normal}"
|
||||||
exit 3
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Check NextCloud webroot
|
## Check NextCloud webroot
|
||||||
@ -453,7 +453,7 @@ if [ -z "$webroot" ]; then
|
|||||||
# no webroot path provided
|
# no webroot path provided
|
||||||
echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \
|
echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
exitWarn+=("${stamp}_5031")
|
exitWarn+=('5031')
|
||||||
clean503=0
|
clean503=0
|
||||||
else
|
else
|
||||||
# verify webroot actually exists
|
# verify webroot actually exists
|
||||||
@ -463,7 +463,7 @@ else
|
|||||||
# webroot directory specified could not be found
|
# webroot directory specified could not be found
|
||||||
echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \
|
echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
exitWarn+=("{$stamp}_5032")
|
exitWarn+=('5032')
|
||||||
clean503=0
|
clean503=0
|
||||||
else
|
else
|
||||||
# webroot exists
|
# webroot exists
|
||||||
@ -476,7 +476,7 @@ else
|
|||||||
# 503 file could not be found
|
# 503 file could not be found
|
||||||
echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \
|
echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
exitWarn+=("${stamp}_5033")
|
exitWarn+=('5033')
|
||||||
clean503=0
|
clean503=0
|
||||||
else
|
else
|
||||||
# 503 file exists and webroot is valid. Let's copy it!
|
# 503 file exists and webroot is valid. Let's copy it!
|
||||||
@ -491,7 +491,7 @@ else
|
|||||||
# copy was unsuccessful
|
# copy was unsuccessful
|
||||||
echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \
|
echo -e "${info}${stamp} -- [INFO] ${warn503} --${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
exitWarn+=("${stamp}_5035")
|
exitWarn+=('5035')
|
||||||
clean503=0
|
clean503=0
|
||||||
else
|
else
|
||||||
# copy was successful
|
# copy was successful
|
||||||
@ -513,7 +513,7 @@ if [ "$maintResult" = "0" ]; then
|
|||||||
echo -e "${info}${stamp} -- [INFO] NextCloud now in maintenance mode --" \
|
echo -e "${info}${stamp} -- [INFO] NextCloud now in maintenance mode --" \
|
||||||
"${normal}" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
else
|
else
|
||||||
exitError+=("${stamp}_100")
|
exitError+=('100')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
fi
|
fi
|
||||||
@ -534,7 +534,7 @@ if [ "$dumpResult" = "0" ]; then
|
|||||||
echo -e "${ok}${stamp} -- [SUCCESS] SQL dumped successfully --${normal}" \
|
echo -e "${ok}${stamp} -- [SUCCESS] SQL dumped successfully --${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
else
|
else
|
||||||
exitError+=("${stamp}_200")
|
exitError+=('200')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
fi
|
fi
|
||||||
@ -552,7 +552,7 @@ mapfile -t borgConfig < "$borgDetails"
|
|||||||
echo -e "${op}${stamp} Verifying supplied borg configuration variables..." \
|
echo -e "${op}${stamp} Verifying supplied borg configuration variables..." \
|
||||||
"${normal}" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
if [ -z "${borgConfig[0]}" ]; then
|
if [ -z "${borgConfig[0]}" ]; then
|
||||||
exitError+=("${stamp}_210")
|
exitError+=('210')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
else
|
else
|
||||||
@ -561,7 +561,7 @@ else
|
|||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = "1" ]; then
|
if [ "$checkResult" = "1" ]; then
|
||||||
# borg base directory specified could not be found
|
# borg base directory specified could not be found
|
||||||
exitError+=("${stamp}_210")
|
exitError+=('210')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
fi
|
fi
|
||||||
@ -570,7 +570,7 @@ else
|
|||||||
fi
|
fi
|
||||||
# check: path to SSH keyfile
|
# check: path to SSH keyfile
|
||||||
if [ -z "${borgConfig[1]}" ]; then
|
if [ -z "${borgConfig[1]}" ]; then
|
||||||
exitError+=("${stamp}_211")
|
exitError+=('211')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
else
|
else
|
||||||
@ -578,7 +578,7 @@ else
|
|||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = 1 ]; then
|
if [ "$checkResult" = 1 ]; then
|
||||||
# SSH keyfile specified could not be found
|
# SSH keyfile specified could not be found
|
||||||
exitError+=("${stamp}_211")
|
exitError+=('211')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
fi
|
fi
|
||||||
@ -587,7 +587,7 @@ else
|
|||||||
fi
|
fi
|
||||||
# check: name of borg repo
|
# check: name of borg repo
|
||||||
if [ -z "${borgConfig[2]}" ]; then
|
if [ -z "${borgConfig[2]}" ]; then
|
||||||
exitError+=("${stamp}_212")
|
exitError+=('212')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
else
|
else
|
||||||
@ -599,7 +599,7 @@ if [ -n "${borgConfig[3]}" ]; then
|
|||||||
echo -e "${op}${stamp} Borg SSH/REPO password... OK${normal}" >> "$logFile"
|
echo -e "${op}${stamp} Borg SSH/REPO password... OK${normal}" >> "$logFile"
|
||||||
export BORG_PASSPHRASE="${borgConfig[3]}"
|
export BORG_PASSPHRASE="${borgConfig[3]}"
|
||||||
else
|
else
|
||||||
exitWarn+=("${stamp}_2111")
|
exitWarn+=('2111')
|
||||||
# if the password was omitted by mistake, export a dummy password so borg
|
# if the password was omitted by mistake, export a dummy password so borg
|
||||||
# fails with an error instead of sitting and waiting for input
|
# fails with an error instead of sitting and waiting for input
|
||||||
export BORG_PASSPHRASE="DummyPasswordSoBorgFails"
|
export BORG_PASSPHRASE="DummyPasswordSoBorgFails"
|
||||||
@ -615,7 +615,7 @@ if [ -n "${borgConfig[7]}" ]; then
|
|||||||
echo -e "${op}${stamp} Borg REMOTE path... OK${normal}" >> "$logFile"
|
echo -e "${op}${stamp} Borg REMOTE path... OK${normal}" >> "$logFile"
|
||||||
export BORG_REMOTE_PATH="${borgConfig[7]}"
|
export BORG_REMOTE_PATH="${borgConfig[7]}"
|
||||||
else
|
else
|
||||||
exitWarn+=("${stamp}_2112")
|
exitWarn+=('2112')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## If borgXtra exists, map contents to an array variable
|
## If borgXtra exists, map contents to an array variable
|
||||||
@ -630,13 +630,13 @@ if [ -n "$borgXtra" ]; then
|
|||||||
echo -e "${op}${stamp} Processed extra files list for inclusion in" \
|
echo -e "${op}${stamp} Processed extra files list for inclusion in" \
|
||||||
"borgbackup${normal}" >> "$logFile"
|
"borgbackup${normal}" >> "$logFile"
|
||||||
else
|
else
|
||||||
exitWarn+=("${stamp}_2113")
|
exitWarn+=('2113')
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# no extra locations specified
|
# no extra locations specified
|
||||||
echo -e "${op}${stamp} No additional locations specified for backup." \
|
echo -e "${op}${stamp} No additional locations specified for backup." \
|
||||||
"Only NextCloud data files will be backed up${normal}" >> "$logFile"
|
"Only NextCloud data files will be backed up${normal}" >> "$logFile"
|
||||||
exitWarn+=("${stamp}_2116")
|
exitWarn+=('2116')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Check if borgExclude exists since borg will throw an error if it's missing
|
## Check if borgExclude exists since borg will throw an error if it's missing
|
||||||
@ -650,7 +650,7 @@ if [ -n "$borgExclude" ]; then
|
|||||||
# file not found, unset the variable so it's like it was not specified
|
# file not found, unset the variable so it's like it was not specified
|
||||||
# in the first place and continue with backup
|
# in the first place and continue with backup
|
||||||
unset borgExclude
|
unset borgExclude
|
||||||
exitWarn+=("${stamp}_2114")
|
exitWarn+=('2114')
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${op}${stamp} Exclusion pattern file not specified." \
|
echo -e "${op}${stamp} Exclusion pattern file not specified." \
|
||||||
@ -682,7 +682,7 @@ if [ "$checkResult" = "1" ]; then
|
|||||||
"${normal}" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
else
|
else
|
||||||
# problem creating folder and script will exit
|
# problem creating folder and script will exit
|
||||||
exitError+=("${stamp}_215")
|
exitError+=('215')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
fi
|
fi
|
||||||
@ -722,13 +722,13 @@ if [ "$borgResult" -eq 0 ]; then
|
|||||||
echo -e "${ok}${stamp} -- [SUCCESS] Borg backup completed successfully --" \
|
echo -e "${ok}${stamp} -- [SUCCESS] Borg backup completed successfully --" \
|
||||||
"${normal}" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
elif [ "$borgResult" -eq 1 ]; then
|
elif [ "$borgResult" -eq 1 ]; then
|
||||||
exitWarn+=("${stamp}_2200")
|
exitWarn+=('2200')
|
||||||
elif [ "$borgResult" -ge 2 ]; then
|
elif [ "$borgResult" -ge 2 ]; then
|
||||||
exitError+=("${stamp}_220")
|
exitError+=('220')
|
||||||
cleanup
|
cleanup
|
||||||
quit
|
quit
|
||||||
else
|
else
|
||||||
exitWarn+=("${stamp}_2201")
|
exitWarn+=('2201')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Generate and execute borg prune
|
## Generate and execute borg prune
|
||||||
@ -745,15 +745,15 @@ if [ -n "$borgPrune" ]; then
|
|||||||
echo -e "${ok}${stamp} -- [SUCCESS] Borg prune completed successfully" \
|
echo -e "${ok}${stamp} -- [SUCCESS] Borg prune completed successfully" \
|
||||||
"--${normal}" >> "$logFile"
|
"--${normal}" >> "$logFile"
|
||||||
elif [ "$pruneResult" -eq 1 ]; then
|
elif [ "$pruneResult" -eq 1 ]; then
|
||||||
exitWarn+=("${stamp}_2210")
|
exitWarn+=('2210')
|
||||||
elif [ "$pruneResult" -ge 2 ]; then
|
elif [ "$pruneResult" -ge 2 ]; then
|
||||||
exitError+=("${stamp}_221")
|
exitError+=('221')
|
||||||
else
|
else
|
||||||
exitWarn+=("${stamp}_2212")
|
exitWarn+=('2212')
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# parameters not defined... skip pruning
|
# parameters not defined... skip pruning
|
||||||
exitWarn+=("${stamp}_2115")
|
exitWarn+=('2115')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user