diff --git a/templates/bin/borgbackup.sh.j2 b/templates/bin/borgbackup.sh.j2 index 9e1b1a3..e7cfa76 100644 --- a/templates/bin/borgbackup.sh.j2 +++ b/templates/bin/borgbackup.sh.j2 @@ -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}