miyagi-backup.sh aktualisiert

fallback without metadata
This commit is contained in:
2025-06-06 00:49:18 +02:00
parent 15b3b5b684
commit 3f9b7c5e64
+24 -6
View File
@@ -101,7 +101,7 @@ run_pbs_backup() {
log "Running PBS vzdump job..." log "Running PBS vzdump job..."
# Storage aktivieren, falls deaktiviert # PBS-Storage ggf. aktivieren
log "Checking if PBS storage '$BACKUPSTORE' is enabled on $SOURCEHOST..." log "Checking if PBS storage '$BACKUPSTORE' is enabled on $SOURCEHOST..."
if ssh root@"$SOURCEHOST" "pvesm status | grep -w '$BACKUPSTORE' | grep -q 'disabled'"; then if ssh root@"$SOURCEHOST" "pvesm status | grep -w '$BACKUPSTORE' | grep -q 'disabled'"; then
log "PBS storage '$BACKUPSTORE' is disabled. Attempting to enable..." log "PBS storage '$BACKUPSTORE' is disabled. Attempting to enable..."
@@ -110,12 +110,30 @@ run_pbs_backup() {
log "PBS storage '$BACKUPSTORE' is already enabled." log "PBS storage '$BACKUPSTORE' is already enabled."
fi fi
# Backup starten # Hauptversuch mit --pbs-change-detection-mode
ssh root@"$SOURCEHOST" vzdump --pbs-change-detection-mode metadata \ if ssh root@"$SOURCEHOST" vzdump --pbs-change-detection-mode metadata \
--node "$SOURCEHOSTNAME" --storage "$BACKUPSTORE" \ --node "$SOURCEHOSTNAME" --storage "$BACKUPSTORE" \
--exclude "$BACKUPEXCLUDE" --mode snapshot --all 1 \ --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 if [[ $? -eq 0 ]]; then
echo "0 DailyPBS - Daily Backup" > /tmp/cmk_tmp.out echo "0 DailyPBS - Daily Backup" > /tmp/cmk_tmp.out
else else
@@ -123,7 +141,7 @@ run_pbs_backup() {
fi fi
( echo "<<<local>>>" ; cat /tmp/cmk_tmp.out ) > /tmp/90000_checkpbs ( echo "<<<local>>>" ; 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() { run_maintenance() {
@@ -197,7 +215,7 @@ main() {
# Funktionsbasierter Aufruf # Funktionsbasierter Aufruf
if [[ "${1:-}" == "help" ]]; then if [[ "${1:-}" == "help" ]]; then
echo "Verfügbare Funktionen:" echo "Verfuegbare Funktionen:"
declare -F | awk '{print " - " $3}' | grep -v "^ - _" declare -F | awk '{print " - " $3}' | grep -v "^ - _"
exit 0 exit 0
elif [[ "${1:-}" =~ ^[a-zA-Z0-9_]+$ && "$(type -t "$1")" == "function" ]]; then elif [[ "${1:-}" =~ ^[a-zA-Z0-9_]+$ && "$(type -t "$1")" == "function" ]]; then