Compare commits
No commits in common. "a299cca365184dad5518f03be81eb17f151e6c76" and "4e5bfa49b4503a8fac5fe9fd476aea84bd7ab162" have entirely different histories.
a299cca365
...
4e5bfa49b4
@ -1,15 +0,0 @@
|
|||||||
### Rotate backup log file
|
|
||||||
|
|
||||||
# location of log file (-l parameter of script file)
|
|
||||||
/path/to/backup.log {
|
|
||||||
|
|
||||||
# rotate log file weekly -- you could also use 'daily', 'monthly' or
|
|
||||||
# specify a size using 'size 100k', for example
|
|
||||||
weekly
|
|
||||||
|
|
||||||
# keep 4 weeks of old logs (4 files) and delete older ones
|
|
||||||
rotate 4
|
|
||||||
|
|
||||||
# compress old log files using gzip (default)
|
|
||||||
compress
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
# Location of your script's log file, -l parameter
|
|
||||||
LogFile = /path/to/your/backup.log
|
|
||||||
|
|
||||||
# Format of logrotate archives for your script. Example assumes compression and
|
|
||||||
# extension preservation
|
|
||||||
Archive = /path/to/your/logfile.ext.?.gz
|
|
||||||
|
|
||||||
# Apply the correct date/time filtering to match the format of the script's log
|
|
||||||
# We are using a custom pl script in /etc/logwatch/scripts/shared/ You don't
|
|
||||||
# need to change this unless you have altered the 'stamp' function in the backup
|
|
||||||
# script in which case you will want to update the regex in the custom pl script
|
|
||||||
# below
|
|
||||||
*sqFullStampAnywhere
|
|
@ -1,9 +0,0 @@
|
|||||||
# Name of the logfile group without any extension
|
|
||||||
LogFile = backup
|
|
||||||
|
|
||||||
# Heading displayed on Logwatch's report for this service
|
|
||||||
Title = "System and Seafile Backup"
|
|
||||||
|
|
||||||
# Override the detail level for this service
|
|
||||||
# Remember the levels are: 0, 1-4, 5, 6+
|
|
||||||
# Detail = 0
|
|
@ -1,112 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
# $Id$
|
|
||||||
#############################################################################
|
|
||||||
# Log: Seafile backup script (seafbackup, Logwatch group 'backup')
|
|
||||||
# Revision 1.1 2019/07/20
|
|
||||||
# Written by Asif Bacchus
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
### Get Logwatch detail level (default to 0)
|
|
||||||
my $detailLevel = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
|
|
||||||
|
|
||||||
|
|
||||||
### Declare variables
|
|
||||||
my $summaryErr;
|
|
||||||
my $summaryWarn;
|
|
||||||
my $summarySuccess;
|
|
||||||
|
|
||||||
my %reportHash = ();
|
|
||||||
my $key;
|
|
||||||
|
|
||||||
|
|
||||||
### Minimal detail level: provide summary data only
|
|
||||||
if ($detailLevel == 0) {
|
|
||||||
### process logfile and summarize message types
|
|
||||||
while (defined(my $ThisLine = <STDIN>)) {
|
|
||||||
if ($ThisLine =~ /\-- \[ERROR\] /) {
|
|
||||||
$summaryErr++;
|
|
||||||
}
|
|
||||||
elsif ($ThisLine =~ /\-- \[WARNING\] /) {
|
|
||||||
$summaryWarn++;
|
|
||||||
}
|
|
||||||
elsif ($ThisLine =~ /All processes completed successfully/) {
|
|
||||||
$summarySuccess++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
### fill hash table with headings and summary counts
|
|
||||||
if ($summarySuccess > 0) {
|
|
||||||
$reportHash{"All processes successfully completed"} = $summarySuccess;
|
|
||||||
}
|
|
||||||
if ($summaryWarn > 0) {
|
|
||||||
$reportHash{"Warnings issued"} = $summaryWarn;
|
|
||||||
}
|
|
||||||
if ($summaryErr > 0) {
|
|
||||||
$reportHash{"Errors encountered"} = $summaryErr;
|
|
||||||
}
|
|
||||||
|
|
||||||
### print hash table
|
|
||||||
foreach $key (sort keys %reportHash) {
|
|
||||||
print "$key: $reportHash{$key}\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
### Levels 1-4 provide the actual error, warning and success messages instead
|
|
||||||
### of a summary count
|
|
||||||
elsif ($detailLevel >= 1 && $detailLevel <= 4) {
|
|
||||||
while (defined(my $ThisLine = <STDIN>)) {
|
|
||||||
if ($ThisLine =~ /\-- \[ERROR\] /) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
elsif ($ThisLine =~ /\-- \[WARNING\] /) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
elsif ($ThisLine =~ /\-- \[SUCCESS\] /) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
### Level 5 is similiar to levels 1-4 except it also reports informational
|
|
||||||
### messages such as the location of script created files, variable checks,
|
|
||||||
### etc. This is useful when verifying the script's operation.
|
|
||||||
elsif ($detailLevel == 5) {
|
|
||||||
while (defined(my $ThisLine = <STDIN>)) {
|
|
||||||
if ($ThisLine =~ /\-- \[ERROR\] /) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
elsif ($ThisLine =~ /\-- \[WARNING\] /) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
elsif ($ThisLine =~ /\-- \[SUCCESS\] /) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
elsif ($ThisLine =~ /\-- \[INFO\] /) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
### Any level above 5 will echo the entire log including the debugging notes
|
|
||||||
### within the script meant for troubleshooting. Using this level of detail
|
|
||||||
### should only be done if you cannot view the actual log file directly for
|
|
||||||
### whatever reason. The actual log file is colour-coded for easier debugging.
|
|
||||||
elsif ($detailLevel > 5) {
|
|
||||||
while (defined(my $ThisLine = <STDIN>)) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Exit gracefully
|
|
||||||
exit (0);
|
|
||||||
|
|
||||||
# vi: shiftwidth=3 tabstop=3 et
|
|
||||||
# Local Variables:
|
|
||||||
# mode: perl
|
|
||||||
# perl-indent-level: 3
|
|
||||||
# indent-tabs-mode: nil
|
|
||||||
# End:
|
|
@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
##########################################################################
|
|
||||||
# $Id$
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
## Filter dates in full-date-time international format, surrounded by square
|
|
||||||
## brackets located anywhere on a given line
|
|
||||||
## Format: '[%Y-%m-%d %H:%M:%S]'
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
use Logwatch ':dates';
|
|
||||||
|
|
||||||
my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
|
|
||||||
|
|
||||||
### Specify the format of the date/time stamp itself
|
|
||||||
$SearchDate = TimeFilter('%Y-%m-%d %H:%M:%S');
|
|
||||||
|
|
||||||
if ( $Debug > 5 ) {
|
|
||||||
print STDERR "DEBUG: Inside FullDateTime...\n";
|
|
||||||
print STDERR "DEBUG: Looking For: " . $SearchDate . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
while (defined($ThisLine = <STDIN>)) {
|
|
||||||
### specify the regex that defines how to find 'SearchDate'
|
|
||||||
if ($ThisLine =~ m/\[$SearchDate\] /o) {
|
|
||||||
print $ThisLine;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# vi: shiftwidth=3 syntax=perl tabstop=3 et
|
|
||||||
# Local Variables:
|
|
||||||
# mode: perl
|
|
||||||
# perl-indent-level: 3
|
|
||||||
# indent-tabs-mode: nil
|
|
||||||
# End:
|
|
@ -62,13 +62,13 @@ borgRepoPassphrase="p@ssW0rd"
|
|||||||
# directories to include in your backup along with Seafile data
|
# directories to include in your backup along with Seafile data
|
||||||
# see repo wiki for more details
|
# see repo wiki for more details
|
||||||
# leave blank if you only want to backup Seafile related files/directories.
|
# leave blank if you only want to backup Seafile related files/directories.
|
||||||
borgXtraListPath="/root/seafileBackup/xtraLocations.borg"
|
borgXtraListPath="/root/seafBackup/xtraLocations.borg"
|
||||||
|
|
||||||
# OPTIONAL: path to file containing files/directories or 'patterns' to be
|
# OPTIONAL: path to file containing files/directories or 'patterns' to be
|
||||||
# excluded in a BORG RECOGNIZED format
|
# excluded in a BORG RECOGNIZED format
|
||||||
# see repo wiki for more details or consult borg documentation
|
# see repo wiki for more details or consult borg documentation
|
||||||
# leave blank for no exclusions.
|
# leave blank for no exclusions.
|
||||||
borgExcludeListPath="/root/seafileBackup/excludeLocations.borg"
|
borgExcludeListPath="/root/seafBackup/excludeLocations.borg"
|
||||||
|
|
||||||
# parameters to determine how borg deletes aged backups
|
# parameters to determine how borg deletes aged backups
|
||||||
# more details in the repo wiki and/or borg documentation
|
# more details in the repo wiki and/or borg documentation
|
||||||
|
@ -53,32 +53,32 @@ cleanup () {
|
|||||||
if [ "$err503Copied" -eq 1 ]; then
|
if [ "$err503Copied" -eq 1 ]; then
|
||||||
if ! rm -f "$webroot/$err503File" 2>>"$logFile"; then
|
if ! rm -f "$webroot/$err503File" 2>>"$logFile"; then
|
||||||
printf "${warn}[%s] -- [WARNING] Could not remove 503 error page." \
|
printf "${warn}[%s] -- [WARNING] Could not remove 503 error page." \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf " Web interface will not function until this file is " \
|
printf " Web interface will not function until this file is " \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
printf "removed --${norm}\n" >> "$logFile"
|
printf "removed --${norm}\n" >> "$logFile"
|
||||||
warnCount=$((warnCount+1))
|
warnCount=$((warnCount+1))
|
||||||
else
|
else
|
||||||
printf "${cyan}[%s] -- [INFO] 503 error page removed --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] 503 error page removed --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$sqlCopied" -eq 1 ]; then
|
if [ "$sqlCopied" -eq 1 ]; then
|
||||||
if ! rm -rf "$sqlDumpDir" 2>>"$logFile"; then
|
if ! rm -rf "$sqlDumpDir" 2>>"$logFile"; then
|
||||||
printf "${warn}[%s] -- [WARNING] Could not remove temporary " \
|
printf "${warn}[%s] -- [WARNING] Could not remove temporary " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "SQL dump directory at %s. " "$sqlDumpDir" >> "$logFile"
|
printf "SQL dump directory at %s. " "$sqlDumpDir" >> "$logFile"
|
||||||
printf "Remove manually to free up space.${norm}\n" >> "$logFile"
|
printf "Remove manually to free up space.${norm}\n" >> "$logFile"
|
||||||
warnCount=$((warnCount+1))
|
warnCount=$((warnCount+1))
|
||||||
else
|
else
|
||||||
printf "${cyan}[%s] -- [INFO] Temporary SQL dump directory " \
|
printf "${cyan}[%s] -- [INFO] Temporary SQL dump directory " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "removed --${norm}\n" >> "$logFile"
|
printf "removed --${norm}\n" >> "$logFile"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$offlineBackup" -eq 1 ]; then
|
if [ "$offlineBackup" -eq 1 ]; then
|
||||||
printf "${cyan}[%s] -- [INFO] Starting seafile services --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Starting seafile services --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
seafSvc start
|
seafSvc start
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -86,11 +86,11 @@ cleanup () {
|
|||||||
# call cleanup and then exit with error report
|
# call cleanup and then exit with error report
|
||||||
exitError () {
|
exitError () {
|
||||||
printf "${err}[%s] -- [ERROR] %s: %s --${norm}\n" \
|
printf "${err}[%s] -- [ERROR] %s: %s --${norm}\n" \
|
||||||
"[$(stamp)]" "$1" "$2" >> "$logFile"
|
"$(stamp)" "$1" "$2" >> "$logFile"
|
||||||
cleanup
|
cleanup
|
||||||
# note script completion with error
|
# note script completion with error
|
||||||
printf "${err}[%s] --- %s execution completed with error ---${norm}\n" \
|
printf "${err}[%s] --- %s execution completed with error ---${norm}\n" \
|
||||||
"[$(stamp)]" "$scriptName" >> "$logFile"
|
"$(stamp)" "$scriptName" >> "$logFile"
|
||||||
exit "$1"
|
exit "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,26 +178,26 @@ seafSvc () {
|
|||||||
exitError 100 "Could not start ${seafService}"
|
exitError 100 "Could not start ${seafService}"
|
||||||
else
|
else
|
||||||
printf "${cyan}[%s] -- [INFO] Started service: %s --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Started service: %s --${norm}\n" \
|
||||||
"[$(stamp)]" "$seafService" >> "$logFile"
|
"$(stamp)" "$seafService" >> "$logFile"
|
||||||
fi
|
fi
|
||||||
if ! systemctl start "${seafHub}" >> "$logFile" 2>&1; then
|
if ! systemctl start "${seafHub}" >> "$logFile" 2>&1; then
|
||||||
exitError 101 "Could not start ${seafHub}"
|
exitError 101 "Could not start ${seafHub}"
|
||||||
else
|
else
|
||||||
printf "${cyan}[%s] -- [INFO] Started service: %s --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Started service: %s --${norm}\n" \
|
||||||
"[$(stamp)]" "$seafHub" >> "$logFile"
|
"$(stamp)" "$seafHub" >> "$logFile"
|
||||||
fi
|
fi
|
||||||
elif [ "$1" = "stop" ]; then
|
elif [ "$1" = "stop" ]; then
|
||||||
if ! systemctl stop "${seafHub}" >> "$logFile" 2>&1; then
|
if ! systemctl stop "${seafHub}" >> "$logFile" 2>&1; then
|
||||||
exitError 103 "Could not stop ${seafHub}"
|
exitError 103 "Could not stop ${seafHub}"
|
||||||
else
|
else
|
||||||
printf "${cyan}[%s] -- [INFO] Stopped service: %s --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Stopped service: %s --${norm}\n" \
|
||||||
"[$(stamp)]" "$seafService" >> "$logFile"
|
"$(stamp)" "$seafService" >> "$logFile"
|
||||||
fi
|
fi
|
||||||
if ! systemctl stop "${seafService}" >> "$logFile" 2>&1; then
|
if ! systemctl stop "${seafService}" >> "$logFile" 2>&1; then
|
||||||
exitError 102 "Could not stop ${seafService}"
|
exitError 102 "Could not stop ${seafService}"
|
||||||
else
|
else
|
||||||
printf "${cyan}[%s] -- [INFO] Stopped service: %s --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Stopped service: %s --${norm}\n" \
|
||||||
"[$(stamp)]" "$seafHub" >> "$logFile"
|
"$(stamp)" "$seafHub" >> "$logFile"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -210,11 +210,11 @@ stamp () {
|
|||||||
# same as exitError but for signal captures
|
# same as exitError but for signal captures
|
||||||
trapExit () {
|
trapExit () {
|
||||||
printf "${err}[%s] -- [ERROR] 99: Caught signal --${norm}\n" \
|
printf "${err}[%s] -- [ERROR] 99: Caught signal --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
cleanup
|
cleanup
|
||||||
# note script completion with error
|
# note script completion with error
|
||||||
printf "${err}[%s] --- %s execution was terminated via signal ---${norm}\n" \
|
printf "${err}[%s] --- %s execution was terminated via signal ---${norm}\n" \
|
||||||
"[$(stamp)]" "$scriptName" >> "$logFile"
|
"$(stamp)" "$scriptName" >> "$logFile"
|
||||||
exit 99
|
exit 99
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,25 +427,25 @@ fi
|
|||||||
|
|
||||||
### start logging
|
### start logging
|
||||||
printf "${magenta}[%s] --- Start %s execution ---${norm}\n" \
|
printf "${magenta}[%s] --- Start %s execution ---${norm}\n" \
|
||||||
"[$(stamp)]" "$scriptName" >> "$logFile"
|
"$(stamp)" "$scriptName" >> "$logFile"
|
||||||
printf "${cyan}[%s] -- [INFO] Log located at ${yellow}%s${cyan} --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Log located at ${yellow}%s${cyan} --${norm}\n" \
|
||||||
"[$(stamp)]" "$logFile" >> "$logFile"
|
"$(stamp)" "$logFile" >> "$logFile"
|
||||||
|
|
||||||
|
|
||||||
### 503 functionality
|
### 503 functionality
|
||||||
if [ "$use503" -eq 1 ]; then
|
if [ "$use503" -eq 1 ]; then
|
||||||
printf "${cyan}[%s] -- [INFO] Copying 503 error page to " \
|
printf "${cyan}[%s] -- [INFO] Copying 503 error page to " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "webroot -- ${norm}\n" >> "$logFile"
|
printf "webroot -- ${norm}\n" >> "$logFile"
|
||||||
if ! \cp --force "${err503Path}" "${webroot}/${err503File}" 2>> "$logFile"
|
if ! \cp --force "${err503Path}" "${webroot}/${err503File}" 2>> "$logFile"
|
||||||
then
|
then
|
||||||
printf "${warn}[%s] -- [WARNING] Failed to copy 503 error page. " \
|
printf "${warn}[%s] -- [WARNING] Failed to copy 503 error page. " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "Web users will NOT be notified --${norm}\n" >> "$logFile"
|
printf "Web users will NOT be notified --${norm}\n" >> "$logFile"
|
||||||
warnCount=$((warnCount+1))
|
warnCount=$((warnCount+1))
|
||||||
else
|
else
|
||||||
printf "${ok}[%s] -- [SUCCESS] 503 error page copied --${norm}\n" \
|
printf "${ok}[%s] -- [SUCCESS] 503 error page copied --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
# set cleanup flag
|
# set cleanup flag
|
||||||
err503Copied=1
|
err503Copied=1
|
||||||
fi
|
fi
|
||||||
@ -455,7 +455,7 @@ fi
|
|||||||
### stop seahub and seafile service if offline backup requested
|
### stop seahub and seafile service if offline backup requested
|
||||||
if [ "$offlineBackup" -eq 1 ]; then
|
if [ "$offlineBackup" -eq 1 ]; then
|
||||||
printf "${cyan}[%s] -- [INFO] Stopping seafile services --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Stopping seafile services --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
seafSvc stop
|
seafSvc stop
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ case "${configDetails}" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf "${cyan}[%s] -- [INFO] ${yellow}%s${cyan} imported --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] ${yellow}%s${cyan} imported --${norm}\n" \
|
||||||
"[$(stamp)]" "$configDetails" >> "$logFile"
|
"$(stamp)" "$configDetails" >> "$logFile"
|
||||||
|
|
||||||
|
|
||||||
### dump sql databases
|
### dump sql databases
|
||||||
@ -499,7 +499,7 @@ fi
|
|||||||
|
|
||||||
## create tmp directory and generate dumpfile names
|
## create tmp directory and generate dumpfile names
|
||||||
printf "${cyan}[%s] -- [INFO] Dumping SQL databases --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Dumping SQL databases --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
# create temporary directory to dump files before borg backup
|
# 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"
|
exitError 111 "Could not create temporary directory to dump SQL files"
|
||||||
@ -507,7 +507,7 @@ fi
|
|||||||
# set cleanup flag
|
# set cleanup flag
|
||||||
sqlCopied=1
|
sqlCopied=1
|
||||||
printf "${cyan}[%s] -- [INFO] SQL dump files will be temporarily stored in:" \
|
printf "${cyan}[%s] -- [INFO] SQL dump files will be temporarily stored in:" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "\n${yellow}%s/${cyan} --${norm}\n" "$sqlDumpDir" >> "$logFile"
|
printf "\n${yellow}%s/${cyan} --${norm}\n" "$sqlDumpDir" >> "$logFile"
|
||||||
# create unique names for database dump files
|
# create unique names for database dump files
|
||||||
sqlDump_ccnet="backup-$(date +%Y%m%d_%H%M%S)_${ccnetDB_name}.sql"
|
sqlDump_ccnet="backup-$(date +%Y%m%d_%H%M%S)_${ccnetDB_name}.sql"
|
||||||
@ -533,17 +533,17 @@ if ! mysqldump -h"${sqlServer}" -u"${sqlUser}" -p"${sqlPass}" \
|
|||||||
exitError 117 "Could not dump ${seahubDB_name} database"
|
exitError 117 "Could not dump ${seahubDB_name} database"
|
||||||
fi
|
fi
|
||||||
printf "${ok}[%s] -- [SUCCESS] SQL databases dumped successfully --${norm}\n" \
|
printf "${ok}[%s] -- [SUCCESS] SQL databases dumped successfully --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
|
|
||||||
|
|
||||||
### pre-backup tasks completed -- move to borg tasks
|
### pre-backup tasks completed -- move to borg tasks
|
||||||
printf "${ok}[%s] -- [SUCCESS] Pre-backup tasks completed --${norm}\n" \
|
printf "${ok}[%s] -- [SUCCESS] Pre-backup tasks completed --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
|
|
||||||
|
|
||||||
### Run borg variable checks
|
### Run borg variable checks
|
||||||
printf "${cyan}[%s] -- [INFO] Verifying supplied borg details --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Verifying supplied borg details --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
|
|
||||||
## verify borg base directory
|
## verify borg base directory
|
||||||
if [ -z "${borgBaseDir}" ]; then
|
if [ -z "${borgBaseDir}" ]; then
|
||||||
@ -635,7 +635,7 @@ if [ ! -d "${borgBaseDir}/tmp" ]; then
|
|||||||
exitError 132 "Unable to create borg ${borgBaseDir}/tmp directory"
|
exitError 132 "Unable to create borg ${borgBaseDir}/tmp directory"
|
||||||
else
|
else
|
||||||
printf "${cyan}[%s] -- [INFO] Created ${yellow}%s/tmp " \
|
printf "${cyan}[%s] -- [INFO] Created ${yellow}%s/tmp " \
|
||||||
"[$(stamp)]" "${borgBaseDir}" >> "$logFile"
|
"$(stamp)" "${borgBaseDir}" >> "$logFile"
|
||||||
printf "${cyan}--${norm}\n" >> "$logFile"
|
printf "${cyan}--${norm}\n" >> "$logFile"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -668,18 +668,18 @@ fi
|
|||||||
|
|
||||||
# execute borg
|
# execute borg
|
||||||
printf "${cyan}[%s] -- [INFO] Executing borg backup operation --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Executing borg backup operation --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
${borgCMD} 2>> "$logFile"
|
${borgCMD} 2>> "$logFile"
|
||||||
borgResult="$?"
|
borgResult="$?"
|
||||||
|
|
||||||
## check borg exit status
|
## check borg exit status
|
||||||
if [ "$borgResult" -eq 0 ]; then
|
if [ "$borgResult" -eq 0 ]; then
|
||||||
printf "${ok}[%s] -- [SUCCESS] Borg backup completed " \
|
printf "${ok}[%s] -- [SUCCESS] Borg backup completed " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "successfully --${norm}\n" >> "$logFile"
|
printf "successfully --${norm}\n" >> "$logFile"
|
||||||
elif [ "$borgResult" -eq 1 ]; then
|
elif [ "$borgResult" -eq 1 ]; then
|
||||||
printf "${warn}[%s] -- [WARNING] Borg completed with warnings. " \
|
printf "${warn}[%s] -- [WARNING] Borg completed with warnings. " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "Review this logfile for details --${norm}\n" >> "$logFile"
|
printf "Review this logfile for details --${norm}\n" >> "$logFile"
|
||||||
warnCount=$((warnCount+1))
|
warnCount=$((warnCount+1))
|
||||||
elif [ "$borgResult" -ge 2 ]; then
|
elif [ "$borgResult" -ge 2 ]; then
|
||||||
@ -688,7 +688,7 @@ elif [ "$borgResult" -ge 2 ]; then
|
|||||||
exitError 138 "$err_1 $err_2"
|
exitError 138 "$err_1 $err_2"
|
||||||
else
|
else
|
||||||
printf "${warn}[%s] -- [WARNING] Borg exited with unknown return code. " \
|
printf "${warn}[%s] -- [WARNING] Borg exited with unknown return code. " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "Review this logfile for details --${norm}\n" >> "$logFile"
|
printf "Review this logfile for details --${norm}\n" >> "$logFile"
|
||||||
warnCount=$((warnCount+1))
|
warnCount=$((warnCount+1))
|
||||||
fi
|
fi
|
||||||
@ -697,13 +697,13 @@ fi
|
|||||||
### execute borg prune if paramters are provided, otherwise skip with a warning
|
### execute borg prune if paramters are provided, otherwise skip with a warning
|
||||||
if [ -n "${borgPruneSettings}" ]; then
|
if [ -n "${borgPruneSettings}" ]; then
|
||||||
printf "${cyan}[%s] -- [INFO] Executing borg prune operation --${norm}\n" \
|
printf "${cyan}[%s] -- [INFO] Executing borg prune operation --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
borg prune --show-rc -v ${borgPruneParams} ${borgPruneSettings} \
|
borg prune --show-rc -v ${borgPruneParams} ${borgPruneSettings} \
|
||||||
2>> "$logFile"
|
2>> "$logFile"
|
||||||
borgPruneResult="$?"
|
borgPruneResult="$?"
|
||||||
else
|
else
|
||||||
printf "${warn}[%s] -- [WARNING] No prune parameters provided. " \
|
printf "${warn}[%s] -- [WARNING] No prune parameters provided. " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "Your archive will continue growing with each backup --${norm}\n" \
|
printf "Your archive will continue growing with each backup --${norm}\n" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
warnCount=$((warnCount+1))
|
warnCount=$((warnCount+1))
|
||||||
@ -713,10 +713,10 @@ fi
|
|||||||
if [ -n "${borgPruneResult}" ]; then
|
if [ -n "${borgPruneResult}" ]; then
|
||||||
if [ "${borgPruneResult}" -eq 0 ]; then
|
if [ "${borgPruneResult}" -eq 0 ]; then
|
||||||
printf "${ok}[%s] -- [SUCCESS] Borg prune completed --${norm}\n" \
|
printf "${ok}[%s] -- [SUCCESS] Borg prune completed --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
elif [ "$borgPruneResult" -eq 1 ]; then
|
elif [ "$borgPruneResult" -eq 1 ]; then
|
||||||
printf "${warn}[%s] -- [WARNING] Borg prune completed with warnings. " \
|
printf "${warn}[%s] -- [WARNING] Borg prune completed with warnings. " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "Review this logfile for details --${norm}\n" >> "$logFile"
|
printf "Review this logfile for details --${norm}\n" >> "$logFile"
|
||||||
warnCount=$((warnCount+1))
|
warnCount=$((warnCount+1))
|
||||||
elif [ "$borgPruneResult" -ge 2 ]; then
|
elif [ "$borgPruneResult" -ge 2 ]; then
|
||||||
@ -725,7 +725,7 @@ if [ -n "${borgPruneResult}" ]; then
|
|||||||
exitError 139 "$err_1 $err_2"
|
exitError 139 "$err_1 $err_2"
|
||||||
else
|
else
|
||||||
printf "${warn}[%s] -- [WARNING] Borg prune exited with an unknown " \
|
printf "${warn}[%s] -- [WARNING] Borg prune exited with an unknown " \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
printf "return code. Review this logfile for details --${norm}\n" \
|
printf "return code. Review this logfile for details --${norm}\n" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
warnCount=$((warnCount+1))
|
warnCount=$((warnCount+1))
|
||||||
@ -737,17 +737,16 @@ fi
|
|||||||
|
|
||||||
# note successful completion of borg commands
|
# note successful completion of borg commands
|
||||||
printf "${ok}[%s] -- [SUCCESS] Backup operations completed --${norm}\n" \
|
printf "${ok}[%s] -- [SUCCESS] Backup operations completed --${norm}\n" \
|
||||||
"[$(stamp)]" >> "$logFile"
|
"$(stamp)" >> "$logFile"
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
# note complete success, tally warnings and exit
|
# note complete success, tally warnings and exit
|
||||||
printf "${ok}[%s] -- [SUCCESS] All processes completed successfully --" \
|
printf "${ok}[%s] -- [SUCCESS] All processes completed --${norm}\n" \
|
||||||
"${norm}\n" \
|
"$(stamp)" >> "$logFile"
|
||||||
"[$(stamp)]" >> "$logFile"
|
|
||||||
printf "${magenta}[%s] --- %s execution completed ---${norm}\n" \
|
printf "${magenta}[%s] --- %s execution completed ---${norm}\n" \
|
||||||
"[$(stamp)]" "$scriptName" >> "$logFile"
|
"$(stamp)" "$scriptName" >> "$logFile"
|
||||||
if [ "$warnCount" -gt 0 ]; then
|
if [ "$warnCount" -gt 0 ]; then
|
||||||
printf "${warn}%s warnings issued!${norm}\n" "${warnCount}" >> "$logFile"
|
printf "${warn}%s warnings issued!${norm}\n" "${warnCount}" >> "$logFile"
|
||||||
else
|
else
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
# root user files
|
# root user files
|
||||||
/root/.bashrc
|
/root/.bashrc
|
||||||
/root/.ssh/
|
/root/.ssh/
|
||||||
/root/seafileBackup/
|
/root/SeafBackup/
|
||||||
|
|
||||||
|
|
||||||
### configuration files for programs related to Seafile
|
### configuration files for programs related to Seafile
|
||||||
|
Loading…
Reference in New Issue
Block a user