From dbcb105ee8b3379756c8f7ea4261aa906b958701 Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 12 Jun 2025 23:14:54 +0200 Subject: [PATCH] miyagi-backup.sh aktualisiert fix piggyback_data --- miyagi-backup.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/miyagi-backup.sh b/miyagi-backup.sh index c9f8a98..3666471 100644 --- a/miyagi-backup.sh +++ b/miyagi-backup.sh @@ -40,10 +40,10 @@ fi # Funktionen set_wol_g_enabled() { - log "Prüfe, ob ethtool installiert ist..." + log "Pruefe, ob ethtool installiert ist..." if ! command -v ethtool >/dev/null 2>&1; then - log "ethtool ist nicht installiert – versuche Installation..." + log "ethtool ist nicht installiert, versuche Installation..." apt update && apt install -y ethtool || { log "Fehler: ethtool konnte nicht installiert werden." return 1 @@ -128,12 +128,23 @@ run_remote_updates() { } send_piggyback_data() { - local fname="90000_miyagi-$SOURCEHOSTNAME-$(hostname)" - log "Sending piggyback data to $SOURCEHOST..." - echo "<<<>>" > "$fname" - /usr/bin/check_mk_agent >> "$fname" - echo "<<<<>>>>" >> "$fname" - scp "$fname" "$SOURCEHOST:/var/lib/check_mk_agent/spool/" + local combined_host="miyagi-${SOURCEHOSTNAME}-$(hostname)" + local filename="90000_${combined_host}" + + log "Don’t forget to add a Host in CMK named: ${combined_host} (without Agent, Piggyback enabled)!" + log "Creating piggyback file: $filename" + + { + echo "<<<<${combined_host}>>>>" + /usr/bin/check_mk_agent + echo "<<<<>>>>" + } > "$filename" + + if scp "$filename" "$SOURCEHOST:/var/lib/check_mk_agent/spool/"; then + log "Piggyback data successfully sent to $SOURCEHOST" + else + log "ERROR: Failed to send piggyback data to $SOURCEHOST" + fi } run_pbs_backup() { @@ -267,7 +278,5 @@ elif [[ "${1:-}" =~ ^[a-zA-Z0-9_]+$ && "$(type -t "$1")" == "function" ]]; then "$FUNC" "$@" exit 0 else - echo "Sleeping for another 60 seconds before starting main routine..." - sleep 60 main -fi \ No newline at end of file +fi