fixed 'Sealfile' typo and updated help text
This commit is contained in:
parent
c48ef84946
commit
9e812b5471
99
backup.sh
99
backup.sh
@ -19,30 +19,29 @@ 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 Sealfile system"
|
echo -e "${default}This script performs a backup of your Seafile system"
|
||||||
echo -e "assuming a fairly standard set up such as outlined at"
|
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 "${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:" \
|
||||||
echo -e "1. Puts Sealfile in maintenance mode."
|
"${normal}${default}"
|
||||||
echo -e "2. Optionally copies a 503 error page to your webroot."
|
echo -e "1. Stops Seafile services and copies a 503 error page to" \
|
||||||
echo -e "3. Dumps SQL to a temporary directory."
|
"your webroot"
|
||||||
echo -e "4. Invokes borgbackup to backup your SQL info, Sealfile program"
|
echo -e "\tto prevent access during backup."
|
||||||
echo -e "\tand data files along with any other files you specify."
|
echo -e "2. Dumps SQL to a temporary directory."
|
||||||
echo -e "5. Removes temp files, the 503 error page and restores"
|
echo -e "3. Invokes borgbackup to backup your SQL info, Seafile program"
|
||||||
echo -e "\tSealfile to operational status."
|
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 "\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, Sealfile data directory${default}"
|
echo -e "${lit}\n-d, Seafile data directory${default}"
|
||||||
echo -e "This is the physical location of your Sealfile data."
|
echo -e "This is the physical location of your Seafile data."
|
||||||
echo -e "${lit}\n-n, Sealfile webroot${default}"
|
echo -e "${lit}\n-u, Seafile system user account${default}"
|
||||||
echo -e "This is the location of the actual Sealfile web files (php & html"
|
echo -e "The system account Seafile is running under. Some actions must"
|
||||||
echo -e ",etc.), usually within your NGINX or Apache webroot."
|
echo -e "run as this user due to file ownership restrictions."
|
||||||
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 "${bold}${note}\nOptional parameters:${normal}${default}"
|
echo -e "${bold}${note}\nOptional parameters:${normal}${default}"
|
||||||
echo -e "${lit}\n-5, Location of 503 error page file${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"
|
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 "${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 Sealfile database."
|
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 ${lit}"
|
echo -e "Details on the structure of this file are in the readme and on"
|
||||||
echo -e "https://mytechiethoughts.com${default}"
|
echo -e "${lit}https://mytechiethoughts.com${default}"
|
||||||
echo -e "${info}Default: ScriptPath/nc_sql.details${default}"
|
echo -e "${info}Default: ScriptPath/nc_sql.details${default}"
|
||||||
echo -e "${lit}\n-v, Verbose output from borgbackup${default}"
|
echo -e "${lit}\n-v, Verbose output from borgbackup${default}"
|
||||||
echo -e "By default, this script will only log summary data from borg."
|
echo -e "By default, this script will only log summary data from borg."
|
||||||
@ -149,7 +148,7 @@ function checkExist {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
### ncMaint - pass requested mode change type to Sealfile occ
|
### ncMaint - pass requested mode change type to Seafile 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 +194,11 @@ function cleanup {
|
|||||||
"nothing to cleanup" >> "$logFile"
|
"nothing to cleanup" >> "$logFile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Exit Sealfile maintenance mode regardless of current status
|
## Exit Seafile 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] Sealfile now in regular" \
|
echo -e "${info}[$(stamp)] -- [INFO] Seafile now in regular" \
|
||||||
"operating mode --${normal}" >> "$logFile"
|
"operating mode --${normal}" >> "$logFile"
|
||||||
else
|
else
|
||||||
exitError+=("[$(stamp)]_101")
|
exitError+=("[$(stamp)]_101")
|
||||||
@ -259,9 +258,9 @@ borgConfig=()
|
|||||||
xtraFiles=()
|
xtraFiles=()
|
||||||
|
|
||||||
### Error codes
|
### Error codes
|
||||||
errorExplain[100]="Could not put Sealfile into maintenance mode"
|
errorExplain[100]="Could not put Seafile into maintenance mode"
|
||||||
errorExplain[101]="Could not exit Sealfile maintenance mode"
|
errorExplain[101]="Could not exit Seafile maintenance mode"
|
||||||
errorExplain[200]="Could not dump Sealfile SQL database"
|
errorExplain[200]="Could not dump Seafile 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 +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[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 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[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 +305,7 @@ while getopts ':l:n:u:v5:w:s:b:d:' PARAMS; do
|
|||||||
logFile="${OPTARG%/}"
|
logFile="${OPTARG%/}"
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
# Sealfile webroot
|
# Seafile webroot
|
||||||
ncRoot="${OPTARG%/}"
|
ncRoot="${OPTARG%/}"
|
||||||
;;
|
;;
|
||||||
u)
|
u)
|
||||||
@ -336,7 +335,7 @@ while getopts ':l:n:u:v5:w:s:b:d:' PARAMS; do
|
|||||||
borgDetails="${OPTARG%/}"
|
borgDetails="${OPTARG%/}"
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
# Sealfile data directory
|
# Seafile data directory
|
||||||
ncDataDir="${OPTARG%/}"
|
ncDataDir="${OPTARG%/}"
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
@ -355,28 +354,28 @@ if [ $(id -u) -ne 0 ]; then
|
|||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Check Sealfile webroot
|
## Check Seafile webroot
|
||||||
# Ensure Sealfile webroot is provided
|
# Ensure Seafile webroot is provided
|
||||||
if [ -z "$ncRoot" ]; then
|
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"
|
"${normal}\n"
|
||||||
exit 1
|
exit 1
|
||||||
# Ensure Sealfile webroot directory exists
|
# Ensure Seafile 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 Sealfile webroot directory could not be found
|
# Specified Seafile webroot directory could not be found
|
||||||
echo -e "\n${err}The provided Sealfile webroot directory" \
|
echo -e "\n${err}The provided Seafile 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 Sealfile webuser account
|
## Check Seafile webuser account
|
||||||
# Ensure Sealfile webuser account is provided
|
# Ensure Seafile webuser account is provided
|
||||||
if [ -z "$webUser" ]; then
|
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"
|
"(-u parameter)${normal}\n"
|
||||||
exit 1
|
exit 1
|
||||||
# Check if supplied webUser account exists
|
# Check if supplied webUser account exists
|
||||||
@ -409,19 +408,19 @@ if [ "$checkResult" = "1" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Check Sealfile data directory
|
## Check Seafile data directory
|
||||||
# Ensure Sealfile data directory is provided
|
# Ensure Seafile data directory is provided
|
||||||
if [ -z "$ncDataDir" ]; then
|
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"
|
"(-d parameter)${normal}\n"
|
||||||
exit 1
|
exit 1
|
||||||
# Ensure Sealfile data directory exists
|
# Ensure Seafile 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 Sealfile data directory could not be found
|
# Specified Seafile data directory could not be found
|
||||||
echo -e "\n${err}The provided Sealfile data directory" \
|
echo -e "\n${err}The provided Seafile data directory" \
|
||||||
"(-d parameter) does not exist.${normal}\n"
|
"(-d parameter) does not exist.${normal}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -510,11 +509,11 @@ fi
|
|||||||
### --- End 503 section ---
|
### --- End 503 section ---
|
||||||
|
|
||||||
|
|
||||||
### Put Sealfile in maintenance mode
|
### Put Seafile 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] Sealfile now in maintenance mode --" \
|
echo -e "${info}[$(stamp)] -- [INFO] Seafile now in maintenance mode --" \
|
||||||
"${normal}" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
else
|
else
|
||||||
exitError+=("[$(stamp)]_100")
|
exitError+=("[$(stamp)]_100")
|
||||||
@ -528,7 +527,7 @@ mapfile -t sqlParams < "$sqlDetails"
|
|||||||
|
|
||||||
|
|
||||||
### Dump SQL
|
### 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]}" \
|
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 +638,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 Sealfile data files will be backed up${normal}" >> "$logFile"
|
"Only Seafile data files will be backed up${normal}" >> "$logFile"
|
||||||
exitWarn+=("[$(stamp)]_2116")
|
exitWarn+=("[$(stamp)]_2116")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user