From 9f9a88540fb4826a98c14b112b4f8bc406adabfb Mon Sep 17 00:00:00 2001 From: misc Date: Fri, 30 May 2025 20:00:23 +0200 Subject: [PATCH] =?UTF-8?q?compact=20eingef=C3=BCgt,=20wenn=20v>1.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- borgbackup.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/borgbackup.sh b/borgbackup.sh index 0cef357..1a2f5cd 100644 --- a/borgbackup.sh +++ b/borgbackup.sh @@ -94,6 +94,7 @@ EOF } + die() { echo "$*" 1>&2 ; exit 1; } ## neues Backup erzeugen @@ -136,6 +137,7 @@ Aufruf $0 keyexport - exportiert Repokey in lokale Datei EOF + } #Repokey zusätzlich lokal speichern @@ -148,7 +150,7 @@ borg_keyexport() { # überprüfen, ob borg-Repository initialisiert wurde # und ausführen, falls nötig borg_check() { - echo "Überprüfe, ob das Repository initialisiert ist..." + echo "Überprüfe, ob das Repository initialisiert ist..." if $BORG check ${BORG_REPO}; then echo "Das Repository ist bereits initialisiert." return 0 @@ -181,10 +183,16 @@ borg_info() { # Anzahl der Sicherungen wird in $BORG_PRUNING festgelegt borg_prune() { echo "Bereinige das Backup-Repository..." - $BORG prune -v --list $BORG_PRUNING "$BORG_REPO" - echo "Compactiere das Backup-Repository..." - # Borg compact command is used to reduce the size of the repository by removing unused data. - $BORG compact "$BORG_REPO" + $BORG prune -v --list $BORG_PRUNING "$BORG_REPO" + + BORG_VERSION=$($BORG -V 2>/dev/null | grep -oE '[0-9]+\.[0-9]+') + MAJOR=$(echo $BORG_VERSION | cut -d. -f1) + MINOR=$(echo $BORG_VERSION | cut -d. -f2) + if [ "$MAJOR" -gt 1 ] || ([ "$MAJOR" -eq 1 ] && [ "$MINOR" -ge 2 ]); then + echo "Borg $BORG_VERSION: führe compact aus" + $BORG compact "$BORG_REPO" + fi + } # auflisten von Borg-Sicherungen