Compare commits

...

4 Commits

Author SHA1 Message Date
muppeth 97cfee4d9c Merge pull request 'Fix logging.' (#2) from log_fix into main
Reviewed-on: #2
Reviewed-by: meaz <meaz@no-reply@disroot.org>
2024-01-03 05:39:40 +00:00
muppeth 67aaf5bd23
fix formatting for xmpp reporting 2023-12-31 21:38:37 +01:00
muppeth 0b0e90130c
fixed logging and reporting to xmpp 2023-12-31 20:53:19 +01:00
muppeth 8aee827880
fixed logging so that it does not remove previous entries 2023-12-31 19:15:38 +01:00
1 changed files with 6 additions and 3 deletions

View File

@ -7,6 +7,7 @@ BORG_SERVER="{{ item.borgserver }}"
BORG_REPO_PATH="{{ borg_backup_dir }}{{ item.hostname }}/{{ item.repo_name }}"
BORG_SOURCE_PATH="{{ item.backup_path }}"
BORG_LOG="{{ borg_log_dir }}{{ item.hostname }}_{{ item.repo_name }}.log"
TEMPBORG_LOG="/tmp/{{ item.hostname }}_{{ item.repo_name }}.log"
BORG_STATS_FILE="{{ borg_log_dir }}{{ item.hostname }}_{{ item.repo_name }}.stats"
BORG_BACKUP_SERVER="${BORG_USER}@${BORG_SERVER}"
@ -18,8 +19,9 @@ if [ ${?} == 2 ]; then
fi
# Run backup keep the last {{ item.retention }} days
borg create --stats ${BORG_BACKUP_SERVER}:${BORG_REPO_PATH}::$(date +'%Y-%m-%dT%H:%M:%S') ${BORG_SOURCE_PATH} > ${BORG_LOG} 2>&1
borg create --stats ${BORG_BACKUP_SERVER}:${BORG_REPO_PATH}::$(date +'%Y-%m-%dT%H:%M:%S') ${BORG_SOURCE_PATH} > ${TEMPBORG_LOG} 2>&1
borg prune --stats -d {{ item.retention }} ${BORG_BACKUP_SERVER}:${BORG_REPO_PATH}
cat ${TEMPBORG_LOG} >> ${BORG_LOG}
{% if item.report_zabbix is defined and item.report_zabbix == 'true' %}
@ -35,8 +37,8 @@ zabbix_sender --tls-connect=psk --tls-psk-identity="Bog Backup" --tls-psk-file=/
{% if item.report_xmpp is defined and item.report_xmpp == 'true' %}
# Send backup report to XMPP
source {{ borg_xmppshouter_cfg }}
echo "💾️ BorgBackup Stats for {{ item.hostname }} - {{ item.repo_name }} 💾️" > ${BORG_STATS_FILE}
borg info ${BORG_BACKUP_SERVER}:${BORG_REPO_PATH} | sed -n '/----------/,$p' >> ${BORG_STATS_FILE}
echo "💾️ BorgBackup Stats for {{ item.hostname }} - {{ item.repo_name }} 💾️" >> ${BORG_STATS_FILE}
awk '/^-+$/ {count++} count==2, count==3 {if(count==1) next; print}' ${TEMPBORG_LOG} >> ${BORG_STATS_FILE}
echo "------------------------------------------------------------------------------" >> ${BORG_STATS_FILE}
cat ${BORG_STATS_FILE} | $SENDXMPP
rm ${BORG_STATS_FILE}
@ -44,4 +46,5 @@ rm ${BORG_STATS_FILE}
#Remove borg password and exit
unset BORG_PASSPHRASE
rm ${TEMPBORG_LOG}