63 lines
2.2 KiB
Plaintext
63 lines
2.2 KiB
Plaintext
# 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 {
|
|
daily
|
|
rotate 7
|
|
missingok
|
|
compress
|
|
su root root
|
|
prerotate
|
|
|
|
filesystem=`df`
|
|
|
|
label=`tune2fs -l $backup_partition | grep -e "Filesystem volume name:" | awk '{print$4}'`
|
|
#label="Root filesystem - /backup"
|
|
|
|
content_type='Content-Type: text/plain;\n charset="utf-8"'
|
|
|
|
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
|
|
|
|
durations_top="\nBackup durations 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:Backup $company -- $datum\n$filesystem\n\ndisk label: $label\n$durations\n\n$send\n" | /usr/sbin/sendmail -F "BACKUP $company" -f $from_address $admin_email
|
|
|
|
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.\nBackupprozess (disk label: $label) 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:Backup 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:Backup Errors $company -- $datum\n${msg}" | /usr/sbin/sendmail -F "Errors BACKUP $company" -f $from_address $extra_error_email
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
endscript
|
|
}
|