dump SQL databases
This commit is contained in:
parent
c65c9113b8
commit
d8c0f0d242
@ -315,6 +315,42 @@ printf "${cyan}[%s] -- [INFO] ${yellow}%s${cyan} imported --${norm}\n" \
|
||||
"$(stamp)" "$configDetails" >> "$logFile"
|
||||
|
||||
|
||||
### dump sql databases
|
||||
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
|
||||
exitError 111 "Could not create temporary directory to dump SQL files"
|
||||
fi
|
||||
printf "${cyan}[%s] -- [INFO] SQL dump files will be temporarily stored in:" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
printf "\n${yellow}%s/${cyan} --${norm}\n" "$sqlDumpDir" >> "$logFile"
|
||||
# create unique names for database dump files
|
||||
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}" \
|
||||
--opt ccnet-db > "${sqlDumpDir}/${sqlDump_ccnet}" 2>> "$logFile"; then
|
||||
exitError 115 "Could not dump ${ccnetDB_name} database"
|
||||
fi
|
||||
# dump SEAFILE-DB
|
||||
if ! mysqldump -h"${sqlServer}" -u"${sqlUser}" -p"${sqlPass}" \
|
||||
--opt ccnet-db > "${sqlDumpDir}/${sqlDump_seafile}" 2>> "$logFile"; then
|
||||
exitError 116 "Could not dump ${seafileDB_name} database"
|
||||
fi
|
||||
# dump CCNET-DB
|
||||
if ! mysqldump -h"${sqlServer}" -u"${sqlUser}" -p"${sqlPass}" \
|
||||
--opt ccnet-db > "${sqlDumpDir}/${sqlDump_seahub}" 2>> "$logFile"; then
|
||||
exitError 117 "Could not dump ${seahubDB_name} database"
|
||||
fi
|
||||
printf "${ok}[%s] -- [SUCCESS] SQL databases dumped successfully --${norm}\n" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
@ -326,3 +362,7 @@ exit 0
|
||||
# 101: could not start seahub service
|
||||
# 102: could not stop seafile service
|
||||
# 103: could not stop seahub service
|
||||
# 111: could not create tmp dir for SQL dump files
|
||||
# 115: could not dump CCNET-DB
|
||||
# 116: could not dump SEAFILE-DB
|
||||
# 117: could not dump SEAHUB-DB
|
Loading…
Reference in New Issue
Block a user