Compare commits

..

No commits in common. "2e66132717ad7dea5396f4a5691d37c281a834ec" and "595ce802306f6cf926d92b096f34a529368396f9" have entirely different histories.

2 changed files with 90 additions and 74 deletions

View File

@ -732,15 +732,6 @@ durationReadable=$(printf "%02d hours %02d minutes %02d seconds" $durationHour $
echo -e "\n\n###### Server backup finished on ${endDateReadable} (${durationReadable}) ######\n" >> ${BORG_LOG_FILE} 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 # Send Summery
# #
@ -765,6 +756,12 @@ if [ $error -gt 0 -o $warning -gt 0 ] ; then
subject_utf8_encoded="=?utf-8?B?$(echo $subject_utf8 | base64 --wrap=0)?=" 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 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
@ -777,23 +774,32 @@ if [ $error -gt 0 -o $warning -gt 0 ] ; then
blank_line 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 # Send Error Message
# #
if $terminal ; then if $terminal ; then
echo -e -n " Send Error Message to ${ADMIN_EMAIL}.." echo -e -n " Send Error Message to ${ADMIN_EMAIL}.."
fi fi
host_name="$(hostname -f)"
err_msg="$(grep -A 2 -i -e"\[\s*ERROR" ${BORG_LOG_FILE})\n" err_msg="$(grep -A 2 -i -e"\[\s*ERROR" ${BORG_LOG_FILE})\n"
warn_msg="$(grep -A 2 -i -e"\[\s*WARN" ${BORG_LOG_FILE})\n" warn_msg="$(grep -A 2 -i -e"\[\s*WARN" ${BORG_LOG_FILE})\n"
msg_top="Borg Backup Error ${COMPANY} vom ${datum}.\nBorg Backup on '$(hostname -f)' beendet mit:" msg_top="Borg Backup Error ${COMPANY} vom ${datum}.\nBorg Backup on '${host_name}' beendet mit:"
msg_body_01="\t${error} Error(s)\n\t${warning} Warning(s)\n" 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_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}" msg="${msg_top}\n${msg_body_01}\n${msg_body_02}"
subject="Borg Backup Errors at ${host_name} -- ${datum}" subject="Borg Backup Errors at ${host_name} -- ${datum}"
#subject="Borg Backup Errors at ${host_name}"
subject_utf8="$(echo "${subject}" | iconv -t UTF8)" subject_utf8="$(echo "${subject}" | iconv -t UTF8)"
subject_utf8_encoded="=?utf-8?B?$(echo ${subject_utf8} | base64 --wrap=0)?=" subject_utf8_encoded="=?utf-8?B?$(echo ${subject_utf8} | base64 --wrap=0)?="
@ -830,7 +836,6 @@ fi
blank_line blank_line
echononl "Create temporary logorotate configuration file 'logrotate_borg.conf'.." echononl "Create temporary logorotate configuration file 'logrotate_borg.conf'.."
cat << EOF > ${LOCK_DIR}/logrotate_borg.conf 2> ${log_file} cat << EOF > ${LOCK_DIR}/logrotate_borg.conf 2> ${log_file}

View File

@ -701,16 +701,10 @@ durationReadable=$(printf "%02d hours %02d minutes %02d seconds" $durationHour $
echo -e "\n\n###### Server backup finished on ${endDateReadable} (${durationReadable}) ######\n" >> ${BORG_LOG_FILE} echo -e "\n\n###### Server backup finished on ${endDateReadable} (${durationReadable}) ######\n" >> ${BORG_LOG_FILE}
blank_line 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 # Send Summery
# #
if $terminal ; then if $terminal ; then
@ -734,6 +728,12 @@ if [ $error -gt 0 -o $warning -gt 0 ] ; then
subject_utf8_encoded="=?utf-8?B?$(echo $subject_utf8 | base64 --wrap=0)?=" 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 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,23 +746,34 @@ if [ $error -gt 0 -o $warning -gt 0 ] ; then
blank_line 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 # Send Error Message
# #
if $terminal ; then if $terminal ; then
echo -e -n " Send Error Message to ${ADMIN_EMAIL}.." echo -e -n " Send Error Message to ${ADMIN_EMAIL}.."
fi fi
#ADMIN_EMAIL="ckubu@oopen.de"
host_name="$(hostname -f)"
err_msg="$(grep -A 2 -i -e"\[\s*ERROR" ${BORG_LOG_FILE})\n" err_msg="$(grep -A 2 -i -e"\[\s*ERROR" ${BORG_LOG_FILE})\n"
warn_msg="$(grep -A 2 -i -e"\[\s*WARN" ${BORG_LOG_FILE})\n" warn_msg="$(grep -A 2 -i -e"\[\s*WARN" ${BORG_LOG_FILE})\n"
msg_top="Borg Backup Error ${COMPANY} vom ${datum}.\nBorg Backup on '$(hostname -f)' beendet mit:" msg_top="Borg Backup Error ${COMPANY} vom ${datum}.\nBorg Backup on '${host_name}' beendet mit:"
msg_body_01="\t${error} Error(s)\n\t${warning} Warning(s)\n" 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_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}" msg="${msg_top}\n${msg_body_01}\n${msg_body_02}"
subject="Borg Backup Errors at ${host_name} -- ${datum}" subject="Borg Backup Errors at ${host_name} -- ${datum}"
#subject="Borg Backup Errors at ${host_name}"
subject_utf8="$(echo "${subject}" | iconv -t UTF8)" subject_utf8="$(echo "${subject}" | iconv -t UTF8)"
subject_utf8_encoded="=?utf-8?B?$(echo ${subject_utf8} | base64 --wrap=0)?=" subject_utf8_encoded="=?utf-8?B?$(echo ${subject_utf8} | base64 --wrap=0)?="