# 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.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/rcopy.log #label durations_top="\nBackup durations of the certain hosts:\n" durations="${durations_top}`cat $logDuration`\n" send=`cat $logFile` datum="$(date +"%d.%m.%Y")" subject="Backup $company -- $datum" subject_utf8="$(echo "$subject" | iconv -t UTF8)" subject_utf8_encoded="=?utf-8?B?$(echo $subject_utf8 | base64 --wrap=0)?=" echo -e "To:${admin_email}\n${content_type}\nSubject:${subject_utf8_encoded}\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:${subject_utf8_encoded}\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}" subject="Backup Errors $company -- $datum" subject_utf8="$(echo "$subject" | iconv -t UTF8)" subject_utf8_encoded="=?utf-8?B?$(echo $subject_utf8 | base64 --wrap=0)?=" echo -e "To:${admin_email}\n${content_type}\nSubject:${subject_utf8_encoded}\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:${subject_utf8_encoded}\n${msg}" | /usr/sbin/sendmail -F "Errors BACKUP $company" -f $from_address $extra_error_email fi fi endscript }