Add logrotation for /var/log/borg/borg-backup.log.

This commit is contained in:
Christoph 2024-10-20 18:30:58 +02:00
parent a35a49dde9
commit 156123e820
2 changed files with 65 additions and 4 deletions

View File

@ -305,7 +305,7 @@ fi
[[ -z "${BORG_RSH}" ]] && BORG_RSH="${DEFAULT_BORG_RSH}"
[[ -z "${BORG_LOG_DIR}" ]] && BORG_LOG_DIR="${DEFAULT_BORG_LOG_DIR}"
BORG_LOG_FILE="${BORG_LOG_DIR}/${backup_date}.log"
BORG_LOG_FILE="${BORG_LOG_DIR}//borg-backup.log"
[[ -z "${NC_DB_BACKUP_DIR}" ]] && NC_DB_BACKUP_DIR="${DEFAULT_NC_DB_BACKUP_DIR}"
@ -690,7 +690,7 @@ echo -e "\n\n###### Server backup finished on ${endDateReadable} (${durationRead
# Send Summery
#
if $terminal ; then
echo -e -n " Send Summary.."
echo -e -n " Send Summary.."
fi
datum="$(date +"%d.%m.%Y %H:%M")"
@ -726,4 +726,33 @@ else
echo_ok
fi
blank_line
echononl "Create temporary logorotate configuration file 'logrotate_borg.conf'.."
cat << EOF > ${LOCK_DIR}/logrotate_borg.conf 2> ${log_file}
$(dirname "${BORG_LOG_FILE}")/* {
daily
rotate 7
missingok
compress
su root root
}
EOF
if [[ $? -gt 0 ]] ; then
echo_failed
error "$(cat "${log_file}")"
else
echo_ok
fi
echononl "Rotate logfile '${BORG_LOG_FILE}'.."
logrotate ${LOCK_DIR}/logrotate_borg.conf > ${log_file} 2>&1
if [[ $? -gt 0 ]] ; then
echo_failed
error "$(cat "${log_file}")"
else
echo_ok
fi
clean_up 0

View File

@ -297,7 +297,7 @@ fi
[[ -z "${DB_BACKUP_DIR}" ]] && DB_BACKUP_DIR="${DEFAULT_DB_BACKUP_DIR}"
[[ -z "${BORG_LOG_DIR}" ]] && BORG_LOG_DIR="${DEFAULT_BORG_LOG_DIR}"
BORG_LOG_FILE="${BORG_LOG_DIR}/${backup_date}.log"
BORG_LOG_FILE="${BORG_LOG_DIR}/borg-backup.log"
[[ -z "${DB_TYPE}" ]] && DB_TYPE="${DEFAULT_DB_TYPE}"
@ -654,10 +654,13 @@ 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
# Send Summery
#
if $terminal ; then
echo -e -n " Send Summary.."
echo -e -n " Send Summary.."
fi
datum="$(date +"%d.%m.%Y %H:%M")"
@ -693,5 +696,34 @@ else
echo_ok
fi
blank_line
echononl "Create temporary logorotate configuration file 'logrotate_borg.conf'.."
cat << EOF > ${LOCK_DIR}/logrotate_borg.conf 2> ${log_file}
$(dirname "${BORG_LOG_FILE}")/* {
daily
rotate 7
missingok
compress
su root root
}
EOF
if [[ $? -gt 0 ]] ; then
echo_failed
error "$(cat "${log_file}")"
else
echo_ok
fi
echononl "Rotate logfile '${BORG_LOG_FILE}'.."
logrotate ${LOCK_DIR}/logrotate_borg.conf > ${log_file} 2>&1
if [[ $? -gt 0 ]] ; then
echo_failed
error "$(cat "${log_file}")"
else
echo_ok
fi
clean_up 0