Only send log messages on errors.

This commit is contained in:
Christoph 2024-12-17 00:26:57 +01:00
parent 595ce80230
commit c7c028abfc
2 changed files with 72 additions and 82 deletions

View File

@ -732,6 +732,15 @@ durationReadable=$(printf "%02d hours %02d minutes %02d seconds" $durationHour $
echo -e "\n\n###### Server backup finished on ${endDateReadable} (${durationReadable}) ######\n" >> ${BORG_LOG_FILE}
blank_line
# Error Handling
#
declare -i error=$(grep -i -e"\[\s*ERROR" ${BORG_LOG_FILE} | wc -l)
declare -i warning=$(grep -i -e"\[\s*WARN" ${BORG_LOG_FILE} | wc -l)
if [ $error -gt 0 -o $warning -gt 0 ] ; then
# Send Summery
#
@ -756,12 +765,6 @@ subject_utf8="$(echo "$subject" | iconv -t UTF8)"
subject_utf8_encoded="=?utf-8?B?$(echo $subject_utf8 | base64 --wrap=0)?="
cat <<EOF >> ${BORG_LOG_FILE}
echo -e "To:${ADMIN_EMAIL}\n${content_type}\nSubject:${subject_utf8_encoded}\n\${filesystem_usage}\n\${msg_head_line}\n\${msg}\n" | /usr/sbin/sendmail -F "Borg BACKUP ${COMPANY}" -f ${FROM_ADDRESS} ${ADMIN_EMAIL}
EOF
echo -e "To:${ADMIN_EMAIL}\n${content_type}\nSubject:${subject_utf8_encoded}\n${filesystem_usage}\n${msg_head_line}\n${msg}\n" | /usr/sbin/sendmail -F "Borg BACKUP ${COMPANY}" -f ${FROM_ADDRESS} ${ADMIN_EMAIL} > ${log_file} 2>&1
@ -774,13 +777,6 @@ fi
blank_line
# Error Handling
#
declare -i error=$(grep -i -e"\[\s*ERROR" ${BORG_LOG_FILE} | wc -l)
declare -i warning=$(grep -i -e"\[\s*WARN" ${BORG_LOG_FILE} | wc -l)
if [ $error -gt 0 -o $warning -gt 0 ] ; then
# Send Error Message
#
if $terminal ; then
@ -836,6 +832,7 @@ fi
blank_line
echononl "Create temporary logorotate configuration file 'logrotate_borg.conf'.."
cat << EOF > ${LOCK_DIR}/logrotate_borg.conf 2> ${log_file}

View File

@ -701,10 +701,16 @@ durationReadable=$(printf "%02d hours %02d minutes %02d seconds" $durationHour $
echo -e "\n\n###### Server backup finished on ${endDateReadable} (${durationReadable}) ######\n" >> ${BORG_LOG_FILE}
blank_line
# Error Handling
#
declare -i error=$(grep -i -e"\[\s*ERROR" ${BORG_LOG_FILE} | wc -l)
declare -i warning=$(grep -i -e"\[\s*WARN" ${BORG_LOG_FILE} | wc -l)
if [ $error -gt 0 -o $warning -gt 0 ] ; then
# Send Summery
#
if $terminal ; then
@ -728,12 +734,6 @@ subject_utf8="$(echo "$subject" | iconv -t UTF8)"
subject_utf8_encoded="=?utf-8?B?$(echo $subject_utf8 | base64 --wrap=0)?="
cat <<EOF >> ${BORG_LOG_FILE}
echo -e "To:${ADMIN_EMAIL}\n${content_type}\nSubject:${subject_utf8_encoded}\n\${filesystem_usage}\n\${msg_head_line}\n\${msg}\n" | /usr/sbin/sendmail -F "Borg BACKUP ${COMPANY}" -f ${FROM_ADDRESS} ${ADMIN_EMAIL}
EOF
echo -e "To:${ADMIN_EMAIL}\n${content_type}\nSubject:${subject_utf8_encoded}\n${filesystem_usage}\n${msg_head_line}\n${msg}\n" | /usr/sbin/sendmail -F "Borg BACKUP ${COMPANY}" -f ${FROM_ADDRESS} ${ADMIN_EMAIL} > ${log_file} 2>&1
@ -746,13 +746,6 @@ fi
blank_line
# Error Handling
#
declare -i error=$(grep -i -e"\[\s*ERROR" ${BORG_LOG_FILE} | wc -l)
declare -i warning=$(grep -i -e"\[\s*WARN" ${BORG_LOG_FILE} | wc -l)
if [ $error -gt 0 -o $warning -gt 0 ] ; then
# Send Error Message
#
if $terminal ; then