From a318cea773244bd268d311aef3b70d9c1b744f7a Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 3 Jun 2025 23:28:12 +0200 Subject: [PATCH] Dateien nach "/" hochladen fix pbs_storage --- miyagi-backup.sh | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/miyagi-backup.sh b/miyagi-backup.sh index 0274569..2ab0c83 100644 --- a/miyagi-backup.sh +++ b/miyagi-backup.sh @@ -28,6 +28,8 @@ while getopts "c:" opt; do done # Bei Einzelaufruf muss Konfiguration geladen sein +shift $((OPTIND - 1)) + if [[ -n "${CONFIG_FILE:-}" ]]; then if [[ ! -f "$CONFIG_FILE" ]]; then log "ERROR: Configuration file not found: $CONFIG_FILE" @@ -93,7 +95,22 @@ send_piggyback_data() { } run_pbs_backup() { + if [[ -z "${SOURCEHOSTNAME:-}" ]]; then + SOURCEHOSTNAME=$(ssh "$SOURCEHOST" hostname) + fi + log "Running PBS vzdump job..." + + # Storage aktivieren, falls deaktiviert + 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..." + ssh root@"$SOURCEHOST" "pvesm set '$BACKUPSTORE' --disable 0 && sleep 2" + else + log "PBS storage '$BACKUPSTORE' is already enabled." + fi + + # Backup starten ssh root@"$SOURCEHOST" vzdump --pbs-change-detection-mode metadata \ --node "$SOURCEHOSTNAME" --storage "$BACKUPSTORE" \ --exclude "$BACKUPEXCLUDE" --mode snapshot --all 1 \ @@ -123,18 +140,18 @@ run_maintenance() { run_scrub_stop_src() { ssh root@"$SOURCEHOST" 'for pool in $(zpool list -H -o name); do - echo "⏹️ Stoppe Scrub auf Pool: $pool" + echo " Stoppe Scrub auf Pool: $pool" zpool scrub -s "$pool" done' } run_scrub_stop_local() { for pool in $(zpool list -H -o name); do - echo "⏹️ Stoppe Scrub auf Pool: $pool" + echo " Stoppe Scrub auf Pool: $pool" if zpool scrub -s "$pool"; then - echo "✔️ Scrub auf $pool gestoppt" + echo " Scrub auf $pool gestoppt" else - echo "❌ Fehler beim Stoppen des Scrubs auf $pool" + echo " Fehler beim Stoppen des Scrubs auf $pool" fi done } @@ -156,13 +173,14 @@ main() { write_zsync_config run_zsync - run_updates run_maintenance run_scrub_stop_local run_scrub_stop_src run_pbs_backup run_remote_updates + run_updates shutdown_if_requested + } # Funktionsbasierter Aufruf @@ -171,8 +189,10 @@ if [[ "${1:-}" == "help" ]]; then declare -F | awk '{print " - " $3}' | grep -v "^ - _" exit 0 elif [[ "${1:-}" =~ ^[a-zA-Z0-9_]+$ && "$(type -t "$1")" == "function" ]]; then + FUNC="$1" shift - "$@" + "$FUNC" "$@" + exit 0 else main fi