change all 'NextCloud' to 'Seafile'

This commit is contained in:
Asif Bacchus 2019-05-18 19:30:15 -06:00
parent 14998f21ca
commit c48ef84946

View File

@ -19,28 +19,28 @@ note="\e[95m"
### scriptHelp -- display usage information for this script ### scriptHelp -- display usage information for this script
function scriptHelp { function scriptHelp {
echo -e "${bold}${note}\n${scriptName} usage instructions:\n${normal}" echo -e "${bold}${note}\n${scriptName} usage instructions:\n${normal}"
echo -e "${default}This script performs a backup of your NextCloud system" echo -e "${default}This script performs a backup of your Sealfile system"
echo -e "assuming a fairly standard set up such as outlined at" echo -e "assuming a fairly standard set up such as outlined at"
echo -e "${lit}https://mytechiethoughts.com${default}. Full details about" echo -e "${lit}https://mytechiethoughts.com${default}. Full details about"
echo -e "this script can be found at that site." echo -e "this script can be found at that site."
echo -e "${bold}\nThe script performs the following tasks:${normal}${default}" echo -e "${bold}\nThe script performs the following tasks:${normal}${default}"
echo -e "1. Puts NextCloud in maintenance mode." echo -e "1. Puts Sealfile in maintenance mode."
echo -e "2. Optionally copies a 503 error page to your webroot." echo -e "2. Optionally copies a 503 error page to your webroot."
echo -e "3. Dumps SQL to a temporary directory." echo -e "3. Dumps SQL to a temporary directory."
echo -e "4. Invokes borgbackup to backup your SQL info, NextCloud program" echo -e "4. Invokes borgbackup to backup your SQL info, Sealfile program"
echo -e "\tand data files along with any other files you specify." echo -e "\tand data files along with any other files you specify."
echo -e "5. Removes temp files, the 503 error page and restores" echo -e "5. Removes temp files, the 503 error page and restores"
echo -e "\tNextCloud to operational status." echo -e "\tSealfile to operational status."
echo -e "\nThe readme file included in this script's git contains detailed" echo -e "\nThe readme file included in this script's git contains detailed"
echo -e "usage information. The following is a brief summary:\n" echo -e "usage information. The following is a brief summary:\n"
echo -e "${bold}${note}Mandatory parameters:${normal}${default}" echo -e "${bold}${note}Mandatory parameters:${normal}${default}"
echo -e "${lit}\n-d, NextCloud data directory${default}" echo -e "${lit}\n-d, Sealfile data directory${default}"
echo -e "This is the physical location of your NextCloud data." echo -e "This is the physical location of your Sealfile data."
echo -e "${lit}\n-n, NextCloud webroot${default}" echo -e "${lit}\n-n, Sealfile webroot${default}"
echo -e "This is the location of the actual NextCloud web files (php & html" echo -e "This is the location of the actual Sealfile web files (php & html"
echo -e ",etc.), usually within your NGINX or Apache webroot." echo -e ",etc.), usually within your NGINX or Apache webroot."
echo -e "${lit}\n-u, NGINX/Apache webuser account${default}" echo -e "${lit}\n-u, NGINX/Apache webuser account${default}"
echo -e "The webuser account NGINX/Apache (and thus, NextCloud) are running" echo -e "The webuser account NGINX/Apache (and thus, Sealfile) are running"
echo -e "under. Some actions must run as this user due to file ownership" echo -e "under. Some actions must run as this user due to file ownership"
echo -e "restrictions." echo -e "restrictions."
echo -e "${bold}${note}\nOptional parameters:${normal}${default}" echo -e "${bold}${note}\nOptional parameters:${normal}${default}"
@ -62,7 +62,7 @@ function scriptHelp {
echo -e "${info}Default: ScriptPath/ScriptName.log${default}" echo -e "${info}Default: ScriptPath/ScriptName.log${default}"
echo -e "${lit}\n-s, Location of file with mySQL details${default}" echo -e "${lit}\n-s, Location of file with mySQL details${default}"
echo -e "FULL PATH to the plain text file containing all information needed" echo -e "FULL PATH to the plain text file containing all information needed"
echo -e "to connect to your mySQL (mariaDB) server and NextCloud database." echo -e "to connect to your mySQL (mariaDB) server and Sealfile database."
echo -e "Details on the structure of this file are in the readme and on ${lit}" echo -e "Details on the structure of this file are in the readme and on ${lit}"
echo -e "https://mytechiethoughts.com${default}" echo -e "https://mytechiethoughts.com${default}"
echo -e "${info}Default: ScriptPath/nc_sql.details${default}" echo -e "${info}Default: ScriptPath/nc_sql.details${default}"
@ -149,7 +149,7 @@ function checkExist {
fi fi
} }
### ncMaint - pass requested mode change type to NextCloud occ ### ncMaint - pass requested mode change type to Sealfile 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
@ -195,11 +195,11 @@ function cleanup {
"nothing to cleanup" >> "$logFile" "nothing to cleanup" >> "$logFile"
fi fi
## Exit NextCloud maintenance mode regardless of current status ## Exit Sealfile maintenance mode regardless of current status
ncMaint off ncMaint off
# check if successful # check if successful
if [ "$maintResult" = "0" ]; then if [ "$maintResult" = "0" ]; then
echo -e "${info}[$(stamp)] -- [INFO] NextCloud now in regular" \ echo -e "${info}[$(stamp)] -- [INFO] Sealfile now in regular" \
"operating mode --${normal}" >> "$logFile" "operating mode --${normal}" >> "$logFile"
else else
exitError+=("[$(stamp)]_101") exitError+=("[$(stamp)]_101")
@ -259,9 +259,9 @@ borgConfig=()
xtraFiles=() xtraFiles=()
### Error codes ### Error codes
errorExplain[100]="Could not put NextCloud into maintenance mode" errorExplain[100]="Could not put Sealfile into maintenance mode"
errorExplain[101]="Could not exit NextCloud maintenance mode" errorExplain[101]="Could not exit Sealfile maintenance mode"
errorExplain[200]="Could not dump NextCloud SQL database" errorExplain[200]="Could not dump Sealfile SQL database"
errorExplain[210]="Invalid or non-existant borg base directory specified (borg backup details file)" errorExplain[210]="Invalid or non-existant borg base directory specified (borg backup details file)"
errorExplain[211]="Invalid or non-existant path to borg SSH keyfile (borg backup details file)" errorExplain[211]="Invalid or non-existant path to borg SSH keyfile (borg backup details file)"
errorExplain[212]="Name of borg repo was not specified (borg backup details file)" errorExplain[212]="Name of borg repo was not specified (borg backup details file)"
@ -282,7 +282,7 @@ warningExplain[2112]="No remote borg instance specified. Operations will be slow
warningExplain[2113]="The specified file containing extra files for inclusion in borgbackup could not be found" warningExplain[2113]="The specified file containing extra files for inclusion in borgbackup could not be found"
warningExplain[2114]="The specified file containing exclusion patterns for borgbackup could not be found. Backup was performed as though NO exclusions were defined" warningExplain[2114]="The specified file containing exclusion patterns for borgbackup could not be found. Backup was performed as though NO exclusions were defined"
warningExplain[2115]="No paramters provided for borg prune. No repo pruning has taken place. You should reconsider this decision to control the size/history of your backups" warningExplain[2115]="No paramters provided for borg prune. No repo pruning has taken place. You should reconsider this decision to control the size/history of your backups"
warningExplain[2116]="No additional locations are specified for inclusion in backup. ONLY NextCloud DATA will be backed up (no configuration, etc). If this is unintentional, check the inclusion file referenced in your borgbackup settings" warningExplain[2116]="No additional locations are specified for inclusion in backup. ONLY Sealfile DATA will be backed up (no configuration, etc). If this is unintentional, check the inclusion file referenced in your borgbackup settings"
warningExplain[2200]="Borg completed with warnings. Please check this script's logfile for details" warningExplain[2200]="Borg completed with warnings. Please check this script's logfile for details"
warningExplain[2201]="Borg exited with an unknown return-code. Please check this script's logfile for details" warningExplain[2201]="Borg exited with an unknown return-code. Please check this script's logfile for details"
warningExplain[2210]="Borg prune exited with warnings. Please check this script's logfile for details" warningExplain[2210]="Borg prune exited with warnings. Please check this script's logfile for details"
@ -306,7 +306,7 @@ while getopts ':l:n:u:v5:w:s:b:d:' PARAMS; do
logFile="${OPTARG%/}" logFile="${OPTARG%/}"
;; ;;
n) n)
# NextCloud webroot # Sealfile webroot
ncRoot="${OPTARG%/}" ncRoot="${OPTARG%/}"
;; ;;
u) u)
@ -336,7 +336,7 @@ while getopts ':l:n:u:v5:w:s:b:d:' PARAMS; do
borgDetails="${OPTARG%/}" borgDetails="${OPTARG%/}"
;; ;;
d) d)
# nextcloud data directory # Sealfile data directory
ncDataDir="${OPTARG%/}" ncDataDir="${OPTARG%/}"
;; ;;
?) ?)
@ -355,28 +355,28 @@ if [ $(id -u) -ne 0 ]; then
exit 3 exit 3
fi fi
## Check NextCloud webroot ## Check Sealfile webroot
# Ensure NextCloud webroot is provided # Ensure Sealfile webroot is provided
if [ -z "$ncRoot" ]; then if [ -z "$ncRoot" ]; then
echo -e "\n${err}The NextCloud webroot must be specified (-n parameter)" \ echo -e "\n${err}The Sealfile webroot must be specified (-n parameter)" \
"${normal}\n" "${normal}\n"
exit 1 exit 1
# Ensure NextCloud webroot directory exists # Ensure Sealfile webroot directory exists
elif [ -n "$ncRoot" ]; then elif [ -n "$ncRoot" ]; then
checkExist fd "$ncRoot" checkExist fd "$ncRoot"
checkResult="$?" checkResult="$?"
if [ "$checkResult" = "1" ]; then if [ "$checkResult" = "1" ]; then
# Specified NextCloud webroot directory could not be found # Specified Sealfile webroot directory could not be found
echo -e "\n${err}The provided NextCloud webroot directory" \ echo -e "\n${err}The provided Sealfile webroot directory" \
"(-n parameter) does not exist.${normal}\n" "(-n parameter) does not exist.${normal}\n"
exit 1 exit 1
fi fi
fi fi
## Check NextCloud webuser account ## Check Sealfile webuser account
# Ensure NextCloud webuser account is provided # Ensure Sealfile webuser account is provided
if [ -z "$webUser" ]; then if [ -z "$webUser" ]; then
echo -e "\n${err}The webuser account running NextCloud must be provided" \ echo -e "\n${err}The webuser account running Sealfile must be provided" \
"(-u parameter)${normal}\n" "(-u parameter)${normal}\n"
exit 1 exit 1
# Check if supplied webUser account exists # Check if supplied webUser account exists
@ -409,19 +409,19 @@ if [ "$checkResult" = "1" ]; then
exit 1 exit 1
fi fi
## Check NextCloud data directory ## Check Sealfile data directory
# Ensure NextCloud data directory is provided # Ensure Sealfile data directory is provided
if [ -z "$ncDataDir" ]; then if [ -z "$ncDataDir" ]; then
echo -e "\n${err}The NextCloud data directory must be specified" \ echo -e "\n${err}The Sealfile data directory must be specified" \
"(-d parameter)${normal}\n" "(-d parameter)${normal}\n"
exit 1 exit 1
# Ensure NextCloud data directory exists # Ensure Sealfile data directory exists
elif [ -n "$ncDataDir" ]; then elif [ -n "$ncDataDir" ]; then
checkExist fd "$ncDataDir" checkExist fd "$ncDataDir"
checkResult="$?" checkResult="$?"
if [ "$checkResult" = "1" ]; then if [ "$checkResult" = "1" ]; then
# Specified NextCloud data directory could not be found # Specified Sealfile data directory could not be found
echo -e "\n${err}The provided NextCloud data directory" \ echo -e "\n${err}The provided Sealfile data directory" \
"(-d parameter) does not exist.${normal}\n" "(-d parameter) does not exist.${normal}\n"
exit 1 exit 1
fi fi
@ -510,11 +510,11 @@ fi
### --- End 503 section --- ### --- End 503 section ---
### Put NextCloud in maintenance mode ### Put Sealfile in maintenance mode
ncMaint on ncMaint on
# check if successful # check if successful
if [ "$maintResult" = "0" ]; then if [ "$maintResult" = "0" ]; then
echo -e "${info}[$(stamp)] -- [INFO] NextCloud now in maintenance mode --" \ echo -e "${info}[$(stamp)] -- [INFO] Sealfile now in maintenance mode --" \
"${normal}" >> "$logFile" "${normal}" >> "$logFile"
else else
exitError+=("[$(stamp)]_100") exitError+=("[$(stamp)]_100")
@ -528,7 +528,7 @@ mapfile -t sqlParams < "$sqlDetails"
### Dump SQL ### Dump SQL
echo -e "${op}[$(stamp)] Dumping NextCloud SQL database...${normal}" >> "$logFile" echo -e "${op}[$(stamp)] Dumping Sealfile SQL database...${normal}" >> "$logFile"
mysqldump --single-transaction -h"${sqlParams[0]}" -u"${sqlParams[1]}" \ mysqldump --single-transaction -h"${sqlParams[0]}" -u"${sqlParams[1]}" \
-p"${sqlParams[2]}" "${sqlParams[3]}" > "${sqlDumpDir}/${sqlDumpFile}" \ -p"${sqlParams[2]}" "${sqlParams[3]}" > "${sqlDumpDir}/${sqlDumpFile}" \
2>> "$logFile" 2>> "$logFile"
@ -639,7 +639,7 @@ if [ -n "$borgXtra" ]; then
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 Sealfile data files will be backed up${normal}" >> "$logFile"
exitWarn+=("[$(stamp)]_2116") exitWarn+=("[$(stamp)]_2116")
fi fi