diff --git a/miyagi-backup.sh b/miyagi-backup.sh index e51f84f..3b4eb1e 100644 --- a/miyagi-backup.sh +++ b/miyagi-backup.sh @@ -101,7 +101,7 @@ run_pbs_backup() { log "Running PBS vzdump job..." - # Storage aktivieren, falls deaktiviert + # PBS-Storage ggf. aktivieren log "Checking if PBS storage '$BACKUPSTORE' is enabled on $SOURCEHOST..." if ssh root@"$SOURCEHOST" "pvesm status | grep -w '$BACKUPSTORE' | grep -q 'disabled'"; then log "PBS storage '$BACKUPSTORE' is disabled. Attempting to enable..." @@ -110,12 +110,30 @@ run_pbs_backup() { log "PBS storage '$BACKUPSTORE' is already enabled." fi - # Backup starten - ssh root@"$SOURCEHOST" vzdump --pbs-change-detection-mode metadata \ + # Hauptversuch mit --pbs-change-detection-mode + if ssh root@"$SOURCEHOST" vzdump --pbs-change-detection-mode metadata \ --node "$SOURCEHOSTNAME" --storage "$BACKUPSTORE" \ --exclude "$BACKUPEXCLUDE" --mode snapshot --all 1 \ - --notes-template '{{guestname}}' + --notes-template '{{guestname}}'; then + log "vzdump with change-detection-mode succeeded" + + else + log "Fallback: vzdump with change-detection-mode failed, trying without it..." + + if ssh root@"$SOURCEHOST" vzdump \ + --node "$SOURCEHOSTNAME" --storage "$BACKUPSTORE" \ + --exclude "$BACKUPEXCLUDE" --mode snapshot --all 1 \ + --notes-template '{{guestname}}'; then + + log "Fallback vzdump succeeded" + + else + log "ERROR: vzdump failed even after fallback" + fi + fi + + # Monitoring-Output if [[ $? -eq 0 ]]; then echo "0 DailyPBS - Daily Backup" > /tmp/cmk_tmp.out else @@ -123,7 +141,7 @@ run_pbs_backup() { fi ( echo "<<>>" ; cat /tmp/cmk_tmp.out ) > /tmp/90000_checkpbs - scp /tmp/90000_checkpbs root@"$SOURCEHOST":/var/lib/check_mk_agent/spool + scp /tmp/90000_checkpbs root@"$SOURCEHOST":/var/lib/check_mk_agent/spool || log "Fehler beim SCP des Monitoring-Outputs" } run_maintenance() { @@ -197,7 +215,7 @@ main() { # Funktionsbasierter Aufruf if [[ "${1:-}" == "help" ]]; then - echo "Verfügbare Funktionen:" + echo "Verfuegbare Funktionen:" declare -F | awk '{print " - " $3}' | grep -v "^ - _" exit 0 elif [[ "${1:-}" =~ ^[a-zA-Z0-9_]+$ && "$(type -t "$1")" == "function" ]]; then