Compare commits
6 Commits
55dc9fac04
...
2b66d9e118
Author | SHA1 | Date |
---|---|---|
Asif Bacchus | 2b66d9e118 | |
Asif Bacchus | d7a8d0ce28 | |
Asif Bacchus | 163bcd2a84 | |
Asif Bacchus | 4a83cdb755 | |
Asif Bacchus | b95981e4bb | |
Asif Bacchus | 68a51bf3c5 |
|
@ -17,6 +17,15 @@ mag=$(tput setaf 5)
|
|||
|
||||
### functions
|
||||
|
||||
# bad configuration value passed in details file
|
||||
badDetails () {
|
||||
if [ "$1" = "empty" ]; then
|
||||
exitError 130 "details:${2} cannot be NULL (undefined)"
|
||||
elif [ "$1" = "dne" ]; then
|
||||
exitError 131 "details:${2} file or directory does not exist."
|
||||
fi
|
||||
}
|
||||
|
||||
# bad parameter passed to script
|
||||
badParam () {
|
||||
if [ "$1" = "dne" ]; then
|
||||
|
@ -128,6 +137,8 @@ borgPruneParams='--list'
|
|||
configDetails="$scriptPath/seafbackup.details"
|
||||
err503Copied=0
|
||||
sqlCopied=0
|
||||
includeXtra=0
|
||||
exclusions=0
|
||||
|
||||
# 503 related
|
||||
use503=0
|
||||
|
@ -401,6 +412,90 @@ printf "${ok}[%s] -- [SUCCESS] SQL databases dumped successfully --${norm}\n" \
|
|||
"$(stamp)" >> "$logFile"
|
||||
|
||||
|
||||
### pre-backup tasks completed -- move to borg tasks
|
||||
printf "${cyan}[%s] -- [INFO] Pre-backup tasks completed --${norm}\n" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
|
||||
|
||||
### Run borg variable checks
|
||||
printf "${cyan}[%s] -- [INFO] Verifying supplied borg details --${norm}\n" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
|
||||
## verify borg base directory
|
||||
if [ -z "${borgBaseDir}" ]; then
|
||||
badDetails empty 'borgBaseDir'
|
||||
elif [ ! -d "${borgBaseDir}" ]; then
|
||||
badDetails dne 'borgBaseDir'
|
||||
fi
|
||||
printf "${magenta}details:borgBaseDir ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
export BORG_BASE_DIR="${borgBaseDir%/}"
|
||||
|
||||
## check path to SSH keyfile
|
||||
if [ -z "${borgSSHKey}" ]; then
|
||||
badDetails empty 'borgSSHKey'
|
||||
elif [ ! -d "${borgSSHKey}" ]; then
|
||||
badDetails dne 'borgSSHKey'
|
||||
fi
|
||||
printf "${magenta}details:borgSSHKey ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
export BORG_RSH="ssh -i ${borgSSHKey}"
|
||||
|
||||
## check borg repo connect string
|
||||
if [ -z "${borgConnectRepo}" ]; then
|
||||
badDetails empty 'borgConnectRepo'
|
||||
fi
|
||||
printf "${magenta}details:borgConnectRepo ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
export BORG_REPO="${borgConnectRepo}"
|
||||
|
||||
## check borg repo password
|
||||
if [ -n "${borgRepoPassphrase}" ]; then
|
||||
printf "${magenta}details:borgRepoPassphrase ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
export BORG_PASSPHRASE="${borgRepoPassphrase}"
|
||||
else
|
||||
# if passwd is blank intentionally, this is insecure
|
||||
printf "${warn} -- [WARNING] Using a borg repo without a password is an " \
|
||||
>> "$logFile"
|
||||
printf "insecure configuration --${norm}\n" >> "$logFile"
|
||||
# if this was an accident, we need to provide a bogus passwd so borg fails
|
||||
# otherwise it will sit forever just waiting for input
|
||||
export BORG_PASSPHRASE="DummyPasswordSoBorgFails"
|
||||
fi
|
||||
|
||||
## read additional files
|
||||
if [ -n "${borgXtraListPath}" ]; then
|
||||
# check if file actually exists
|
||||
if [ ! -f "${borgXtraListPath}" ]; then
|
||||
badDetails dne 'borgXtraListPath'
|
||||
fi
|
||||
# read file contents into concatenated list for echo to cmdline
|
||||
while read -r xtraItem; do
|
||||
if [ -z "${xtraList}" ]; then
|
||||
xtraList="${xtraItem}"
|
||||
else
|
||||
xtraList="${xtraList} ${xtraItem}"
|
||||
fi
|
||||
done <<EOF
|
||||
$( sed -e '/^\s*#.*$/d' -e '/^\s*$/d' "${borgXtraListPath}" )
|
||||
EOF
|
||||
printf "${magenta}details:borgXtraListPath ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
includeXtra=1
|
||||
fi
|
||||
|
||||
## check if exlusion list file is specified
|
||||
if [ -n "${borgExcludeListPath}" ]; then
|
||||
# check if the file actually exists
|
||||
if [ ! -f "${borgExcludeListPath}" ]; then
|
||||
badDetails dne 'borgExcludeListPath'
|
||||
fi
|
||||
exclusions=1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -418,3 +513,5 @@ exit 0
|
|||
# 115: could not dump CCNET-DB
|
||||
# 116: could not dump SEAFILE-DB
|
||||
# 117: could not dump SEAHUB-DB
|
||||
# 130: null borg configuration variable
|
||||
# 131: invalid borg configuration variable
|
Loading…
Reference in New Issue