Compare commits
3 Commits
090ce7d7fb
...
5e7d2fe6d2
Author | SHA1 | Date |
---|---|---|
Asif Bacchus | 5e7d2fe6d2 | |
Asif Bacchus | 62107ed611 | |
Asif Bacchus | f33f4824fa |
|
@ -12,7 +12,7 @@ warn=$(tput bold)$(tput setaf 3)
|
|||
ok=$(tput setaf 2)
|
||||
yellow=$(tput setaf 3)
|
||||
cyan=$(tput setaf 6)
|
||||
mag=$(tput setaf 5)
|
||||
magenta=$(tput setaf 5)
|
||||
|
||||
|
||||
### functions
|
||||
|
@ -330,7 +330,7 @@ fi
|
|||
|
||||
|
||||
### start logging
|
||||
printf "${mag}[%s] --- Start %s execution ---${norm}\n" \
|
||||
printf "${magenta}[%s] --- Start %s execution ---${norm}\n" \
|
||||
"$(stamp)" "$scriptName" >> "$logFile"
|
||||
printf "${cyan}[%s] -- [INFO] Log located at ${yellow}%s${cyan} --${norm}\n" \
|
||||
"$(stamp)" "$logFile" >> "$logFile"
|
||||
|
@ -381,10 +381,26 @@ printf "${cyan}[%s] -- [INFO] ${yellow}%s${cyan} imported --${norm}\n" \
|
|||
|
||||
|
||||
### dump sql databases
|
||||
|
||||
## verify SQL variables are defined in details file
|
||||
# sqlServer
|
||||
if [ -z "${sqlServer}" ]; then
|
||||
badDetails empty 'sqlServer'
|
||||
fi
|
||||
# sqlUser
|
||||
if [ -z "${sqlUser}" ]; then
|
||||
badDetails empty 'sqlUser'
|
||||
fi
|
||||
# sqlPass
|
||||
if [ -z "${sqlPass}" ]; then
|
||||
badDetails empty 'sqlPass'
|
||||
fi
|
||||
|
||||
## create tmp directory and generate dumpfile names
|
||||
printf "${cyan}[%s] -- [INFO] Dumping SQL databases --${norm}\n" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
# create temporary directory to dump files before borg backup
|
||||
if ! sqlDumpDir=$( mktemp -d 2>>"$logFile"); then
|
||||
if ! sqlDumpDir=$( mktemp -d 2>>"$logFile" ); then
|
||||
exitError 111 "Could not create temporary directory to dump SQL files"
|
||||
fi
|
||||
# set cleanup flag
|
||||
|
@ -396,6 +412,7 @@ printf "\n${yellow}%s/${cyan} --${norm}\n" "$sqlDumpDir" >> "$logFile"
|
|||
sqlDump_ccnet="backup-$(date +%Y%m%d_%H%M%S)_${ccnetDB_name}.sql"
|
||||
sqlDump_seafile="backup-$(date +%Y%m%d_%H%M%S)_${seafileDB_name}.sql"
|
||||
sqlDump_seahub="backup-$(date +%Y%m%d_%H%M%S)_${seahubDB_name}.sql"
|
||||
|
||||
## dump databases
|
||||
# dump CCNET-DB
|
||||
if ! mysqldump -h"${sqlServer}" -u"${sqlUser}" -p"${sqlPass}" \
|
||||
|
@ -432,7 +449,7 @@ elif [ ! -d "${borgBaseDir}" ]; then
|
|||
badDetails dne 'borgBaseDir'
|
||||
fi
|
||||
printf "${magenta}details:borgBaseDir ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
>> "$logFile"
|
||||
export BORG_BASE_DIR="${borgBaseDir%/}"
|
||||
|
||||
## check path to SSH keyfile
|
||||
|
@ -442,7 +459,7 @@ elif [ ! -d "${borgSSHKey}" ]; then
|
|||
badDetails dne 'borgSSHKey'
|
||||
fi
|
||||
printf "${magenta}details:borgSSHKey ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
>> "$logFile"
|
||||
export BORG_RSH="ssh -i ${borgSSHKey}"
|
||||
|
||||
## check borg repo connect string
|
||||
|
@ -450,13 +467,13 @@ if [ -z "${borgConnectRepo}" ]; then
|
|||
badDetails empty 'borgConnectRepo'
|
||||
fi
|
||||
printf "${magenta}details:borgConnectRepo ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
>> "$logFile"
|
||||
export BORG_REPO="${borgConnectRepo}"
|
||||
|
||||
## check borg repo password
|
||||
if [ -n "${borgRepoPassphrase}" ]; then
|
||||
printf "${magenta}details:borgRepoPassphrase ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
>> "$logFile"
|
||||
export BORG_PASSPHRASE="${borgRepoPassphrase}"
|
||||
else
|
||||
# if passwd is blank intentionally, this is insecure
|
||||
|
@ -489,7 +506,7 @@ if [ -n "${borgXtraListPath}" ]; then
|
|||
$( sed -e '/^\s*#.*$/d' -e '/^\s*$/d' "${borgXtraListPath}" )
|
||||
EOF
|
||||
printf "${magenta}details:borgXtraListPath ${norm}-- ${ok}[OK]${norm}\n" \
|
||||
>> "$logfile"
|
||||
>> "$logFile"
|
||||
includeXtra=1
|
||||
fi
|
||||
|
||||
|
@ -578,7 +595,7 @@ fi
|
|||
if [ -n "${borgPruneSettings}" ]; then
|
||||
printf "${cyan}[%s] -- [INFO] Executing borg prune operation --${norm}\n" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
borg prune --show-rc -v ${borgPruneParams} ${borgPruneSettings} \
|
||||
borg prune --show-rc -v "${borgPruneParams}" "${borgPruneSettings}" \
|
||||
2>> "$logFile"
|
||||
borgPruneResult="$?"
|
||||
else
|
||||
|
@ -625,7 +642,7 @@ cleanup
|
|||
# note complete success, tally warnings and exit
|
||||
printf "${ok}[%s] -- [SUCCESS] All processes completed --${norm}\n" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
printf "${mag}[%s] --- %s execution completed ---${norm}\n" \
|
||||
printf "${magenta}[%s] --- %s execution completed ---${norm}\n" \
|
||||
"$(stamp)" "$scriptName" >> "$logFile"
|
||||
if [ "$warnCount" -gt 0 ]; then
|
||||
printf "${warn}%s warnings issued!${norm}\n" "${warnCount}" >> "$logFile"
|
||||
|
|
Loading…
Reference in New Issue