fixed 'Sealfile' typo and updated help text

This commit is contained in:
Asif Bacchus 2019-05-18 19:44:27 -06:00
parent c48ef84946
commit 9e812b5471
1 changed files with 49 additions and 50 deletions

View File

@ -19,30 +19,29 @@ note="\e[95m"
### scriptHelp -- display usage information for this script
function scriptHelp {
echo -e "${bold}${note}\n${scriptName} usage instructions:\n${normal}"
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 "${default}This script performs a backup of your Seafile system"
echo -e "assuming a fairly standard baremetal set up such as outlined at"
echo -e "${lit}https://mytechiethoughts.com${default}. Full details about"
echo -e "this script can be found at that site."
echo -e "${bold}\nThe script performs the following tasks:${normal}${default}"
echo -e "1. Puts Sealfile in maintenance mode."
echo -e "2. Optionally copies a 503 error page to your webroot."
echo -e "3. Dumps SQL to a temporary directory."
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 "5. Removes temp files, the 503 error page and restores"
echo -e "\tSealfile to operational status."
echo -e "${bold}\nThe script performs the following tasks:" \
"${normal}${default}"
echo -e "1. Stops Seafile services and copies a 503 error page to" \
"your webroot"
echo -e "\tto prevent access during backup."
echo -e "2. Dumps SQL to a temporary directory."
echo -e "3. Invokes borgbackup to backup your SQL info, Seafile program"
echo -e "and data files"
echo -e "\talong with any other files you specify."
echo -e "3. Prunes old backups from borgbackup repo."
echo -e "4. Removes 503 page and cleans up."
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 "${bold}${note}Mandatory parameters:${normal}${default}"
echo -e "${lit}\n-d, Sealfile data directory${default}"
echo -e "This is the physical location of your Sealfile data."
echo -e "${lit}\n-n, Sealfile webroot${default}"
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 "${lit}\n-u, NGINX/Apache webuser account${default}"
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 "restrictions."
echo -e "${lit}\n-d, Seafile data directory${default}"
echo -e "This is the physical location of your Seafile data."
echo -e "${lit}\n-u, Seafile system user account${default}"
echo -e "The system account Seafile is running under. Some actions must"
echo -e "run as this user due to file ownership restrictions."
echo -e "${bold}${note}\nOptional parameters:${normal}${default}"
echo -e "${lit}\n-5, Location of 503 error page file${default}"
echo -e "FULL PATH to the 503 error page HTML file you want copied to your"
@ -62,9 +61,9 @@ function scriptHelp {
echo -e "${info}Default: ScriptPath/ScriptName.log${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 "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 "https://mytechiethoughts.com${default}"
echo -e "to connect to your mySQL (mariaDB) server and Seafile database."
echo -e "Details on the structure of this file are in the readme and on"
echo -e "${lit}https://mytechiethoughts.com${default}"
echo -e "${info}Default: ScriptPath/nc_sql.details${default}"
echo -e "${lit}\n-v, Verbose output from borgbackup${default}"
echo -e "By default, this script will only log summary data from borg."
@ -149,7 +148,7 @@ function checkExist {
fi
}
### ncMaint - pass requested mode change type to Sealfile occ
### ncMaint - pass requested mode change type to Seafile occ
function ncMaint {
sudo -u "${webUser}" php "${ncRoot}/occ" maintenance:mode --"$1" \
>> "$logFile" 2>&1
@ -195,11 +194,11 @@ function cleanup {
"nothing to cleanup" >> "$logFile"
fi
## Exit Sealfile maintenance mode regardless of current status
## Exit Seafile maintenance mode regardless of current status
ncMaint off
# check if successful
if [ "$maintResult" = "0" ]; then
echo -e "${info}[$(stamp)] -- [INFO] Sealfile now in regular" \
echo -e "${info}[$(stamp)] -- [INFO] Seafile now in regular" \
"operating mode --${normal}" >> "$logFile"
else
exitError+=("[$(stamp)]_101")
@ -259,9 +258,9 @@ borgConfig=()
xtraFiles=()
### Error codes
errorExplain[100]="Could not put Sealfile into maintenance mode"
errorExplain[101]="Could not exit Sealfile maintenance mode"
errorExplain[200]="Could not dump Sealfile SQL database"
errorExplain[100]="Could not put Seafile into maintenance mode"
errorExplain[101]="Could not exit Seafile maintenance mode"
errorExplain[200]="Could not dump Seafile SQL database"
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[212]="Name of borg repo was not specified (borg backup details file)"
@ -282,7 +281,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[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[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[2116]="No additional locations are specified for inclusion in backup. ONLY Seafile 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[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"
@ -306,7 +305,7 @@ while getopts ':l:n:u:v5:w:s:b:d:' PARAMS; do
logFile="${OPTARG%/}"
;;
n)
# Sealfile webroot
# Seafile webroot
ncRoot="${OPTARG%/}"
;;
u)
@ -336,7 +335,7 @@ while getopts ':l:n:u:v5:w:s:b:d:' PARAMS; do
borgDetails="${OPTARG%/}"
;;
d)
# Sealfile data directory
# Seafile data directory
ncDataDir="${OPTARG%/}"
;;
?)
@ -355,28 +354,28 @@ if [ $(id -u) -ne 0 ]; then
exit 3
fi
## Check Sealfile webroot
# Ensure Sealfile webroot is provided
## Check Seafile webroot
# Ensure Seafile webroot is provided
if [ -z "$ncRoot" ]; then
echo -e "\n${err}The Sealfile webroot must be specified (-n parameter)" \
echo -e "\n${err}The Seafile webroot must be specified (-n parameter)" \
"${normal}\n"
exit 1
# Ensure Sealfile webroot directory exists
# Ensure Seafile webroot directory exists
elif [ -n "$ncRoot" ]; then
checkExist fd "$ncRoot"
checkResult="$?"
if [ "$checkResult" = "1" ]; then
# Specified Sealfile webroot directory could not be found
echo -e "\n${err}The provided Sealfile webroot directory" \
# Specified Seafile webroot directory could not be found
echo -e "\n${err}The provided Seafile webroot directory" \
"(-n parameter) does not exist.${normal}\n"
exit 1
fi
fi
## Check Sealfile webuser account
# Ensure Sealfile webuser account is provided
## Check Seafile webuser account
# Ensure Seafile webuser account is provided
if [ -z "$webUser" ]; then
echo -e "\n${err}The webuser account running Sealfile must be provided" \
echo -e "\n${err}The webuser account running Seafile must be provided" \
"(-u parameter)${normal}\n"
exit 1
# Check if supplied webUser account exists
@ -409,19 +408,19 @@ if [ "$checkResult" = "1" ]; then
exit 1
fi
## Check Sealfile data directory
# Ensure Sealfile data directory is provided
## Check Seafile data directory
# Ensure Seafile data directory is provided
if [ -z "$ncDataDir" ]; then
echo -e "\n${err}The Sealfile data directory must be specified" \
echo -e "\n${err}The Seafile data directory must be specified" \
"(-d parameter)${normal}\n"
exit 1
# Ensure Sealfile data directory exists
# Ensure Seafile data directory exists
elif [ -n "$ncDataDir" ]; then
checkExist fd "$ncDataDir"
checkResult="$?"
if [ "$checkResult" = "1" ]; then
# Specified Sealfile data directory could not be found
echo -e "\n${err}The provided Sealfile data directory" \
# Specified Seafile data directory could not be found
echo -e "\n${err}The provided Seafile data directory" \
"(-d parameter) does not exist.${normal}\n"
exit 1
fi
@ -510,11 +509,11 @@ fi
### --- End 503 section ---
### Put Sealfile in maintenance mode
### Put Seafile in maintenance mode
ncMaint on
# check if successful
if [ "$maintResult" = "0" ]; then
echo -e "${info}[$(stamp)] -- [INFO] Sealfile now in maintenance mode --" \
echo -e "${info}[$(stamp)] -- [INFO] Seafile now in maintenance mode --" \
"${normal}" >> "$logFile"
else
exitError+=("[$(stamp)]_100")
@ -528,7 +527,7 @@ mapfile -t sqlParams < "$sqlDetails"
### Dump SQL
echo -e "${op}[$(stamp)] Dumping Sealfile SQL database...${normal}" >> "$logFile"
echo -e "${op}[$(stamp)] Dumping Seafile SQL database...${normal}" >> "$logFile"
mysqldump --single-transaction -h"${sqlParams[0]}" -u"${sqlParams[1]}" \
-p"${sqlParams[2]}" "${sqlParams[3]}" > "${sqlDumpDir}/${sqlDumpFile}" \
2>> "$logFile"
@ -639,7 +638,7 @@ if [ -n "$borgXtra" ]; then
else
# no extra locations specified
echo -e "${op}[$(stamp)] No additional locations specified for backup." \
"Only Sealfile data files will be backed up${normal}" >> "$logFile"
"Only Seafile data files will be backed up${normal}" >> "$logFile"
exitWarn+=("[$(stamp)]_2116")
fi