Add Options 'ONLY_BACKUP' (do not handle existing archives) and 'NO_NEW_BACKUP' (do not backup any host, only handle existing archives).

This commit is contained in:
2020-05-23 15:33:39 +02:00
parent 41e67196d3
commit e6e88c7e7d
7 changed files with 367 additions and 180 deletions

View File

@ -1,7 +1,7 @@
# I put everything in one block and added sharedscripts, so that mysql gets
# flush-logs'd only once.
# Else the binary logs would automatically increase by n times every day.
/var/log/rsync.log {
/var/log/rcopy.log {
daily
rotate 7
missingok

View File

@ -0,0 +1,64 @@
# I put everything in one block and added sharedscripts, so that mysql gets
# flush-logs'd only once.
# Else the binary logs would automatically increase by n times every day.
/var/log/rcopy-handle_backups.log {
daily
rotate 7
missingok
compress
su root root
prerotate
filesystem=`df`
content_type='Content-Type: text/plain;\n charset="utf-8"'
extra_admin_email=""
extra_error_email=""
## - These variables will be exportet from backup script (rcopy.sh)
## -
## - admin_email from_address company logFile logDuration
#admin_email="argus@oopen.de"
#from_address="root@`hostname -f`"
#company="Warenform INET"
#logFile=/backup/log/rsync.log
#label
durations_top="\nDurations of the certain hosts:\n"
durations="${durations_top}`cat $logDuration`\n"
send=`cat $logFile`
datum=`date +"%d.%m.%Y"`
echo -e "To:${admin_email}\n${content_type}\nSubject:Handle Backups $company -- $datum\n$filesystem\n\nBackup resource / Label: $label\n$durations\n\n$send\n" | /usr/sbin/sendmail -F "BACKUP $company" -f $from_address $admin_email
if [[ -n "$extra_admin_email" ]]; then
echo -e "To:${extra_admin_email}\n${content_type}\nSubject:Handle Backups $company -- $datum\n$filesystem\n\nBackup resource / Labe: $label\n$durations\n\n$send\n" | /usr/sbin/sendmail -F "BACKUP $company" -f $from_address $extra_admin_email
fi
declare -i error=`grep -e"\[ERROR" $logFile | wc -l`
declare -i warning=`grep -e"\[WARN" $logFile | wc -l`
if [ $error -gt 0 -o $warning -gt 0 ] ; then
err_msg="`grep -A 2 -B 1 -e\"\[ERROR\" $logFile`\n"
warn_msg="`grep -A 2 -B 2 -e\"\[WARN\" $logFile`\n"
msg_top="Backup $company vom $datum.\nBackup resource / Label: $label\nBackupprozess beendet mit:"
msg_body_01="\t$error Error(s)\n\t$warning Warning(s)\n"
msg_body_02="\n\n--- ERROR(S) ---\n${err_msg}\n\n--- WARNING(S) ...\n${warn_msg}"
msg="${msg_top}\n${msg_body_01}\n${msg_body_02}"
echo -e "To:${admin_email}\n${content_type}\nSubject:Handle Backups Errors $company -- $datum\n${msg}" | /usr/sbin/sendmail -F "Errors BACKUP $company" -f $from_address $admin_email
if [ "X$extra_error_email" != "X" ]; then
echo -e "To:${extra_error_email}\n${content_type}\nSubject:Handle Backups Errors $company -- $datum\n${msg}" | /usr/sbin/sendmail -F "Errors BACKUP $company" -f $from_address $extra_error_email
fi
fi
endscript
}

View File

@ -137,11 +137,6 @@ reminder_email_2=""
backup_base_dir=${backup_mountpoint}/backup
#backup_base_dir=/backup
## - location of the logfile
## -
logFile="/var/log/rsync.log"
disk_label_log_file="/var/log/backup_disk-label.log"
## - logging backup durations in an different file
## - NOTICE:
## - because of the process number in the filename, take care, not to

View File

@ -5,6 +5,64 @@
# --------------------------------------------------- #
# ------------------- Funktionen -------------------- #
#
usage() {
[[ -n "$1" ]] && error "$1"
echo -e "
\033[1mUsage:\033[m
$(basename $0) [OPTION [OPTION ..
\033[1mDescription\033[m
Main Backup Script for hosts maintained by O.OPEN.
\033[1mOptions\033[m
-B
Only Backup host - do not handle (existing) archives.
-N
Do not backup anything, only maintain existing backups - archiving and/or
removing existing backups.
-m
Only backup hosts listed in file conf/manual_hosts.conf. Don't inform anyone,
and also don't restart services.
\033[1mFiles\033[m
\033[1m$(basename $rcopy_conf_file)\033[m: Main Configuration
See folder 'conf' for more configuration files
\033[1mExample:\033[m
Normal Backup
$(basename $0)
Only maintain backup archives - do NOT write new backups
$(basename $0) -N
"
clean_up 1
}
clean_up() {
# Perform program exit housekeeping
rm -rf "$LOCK_DIR"
blank_line
exit $1
}
echolog(){
if [ -n "$2" ];then
case $_DEBUG in
@ -55,6 +113,11 @@ fatal(){
echolog "\n*** End Update -- no backups are done ***\n\n"
exit 1
}
blank_line() {
echo ""
}
#
# ------------------ Ende Funktionen ---------------- #
# --------------------------------------------------- #