Update sync-pbs-to-ssd4to.sh

This commit is contained in:
Ssyleric
2025-11-03 17:14:22 +01:00
committed by GitHub
parent 9b3131fb56
commit 38506715f1

View File

@@ -35,7 +35,7 @@ bytes_human(){ numfmt --to=iec --suffix=B --padding=7 "$1"; }
### ======= CHECKS =======
mkdir -p "$LOG_DIR" "$DST"
umask 022
log "▶️ Démarrage COPIE PBS → PVE"
log "▶️ Démarrage COPIE PBS → PVE (--delete)"
log "PBS_IP=${PBS_IP} | SRC=${SRC} | DST=${DST} | LOG=${LOG}"
# Pré-requis côté PVE
@@ -73,10 +73,10 @@ DST_AVAIL_BYTES=$(df -B1 "$DST" | awk 'NR==2{print $4}')
DST_AVAIL_HUM=$(bytes_human "$DST_AVAIL_BYTES")
log "Taille source : ${SRC_HUM} | Espace dispo cible : ${DST_AVAIL_HUM}"
### ======= COPIE UNIQUE (SANS DELETE) =======
log "🟦 Copie (sans --delete)…"
### ======= COPIE AVEC DELETE =======
log "🟦 Copie démarrée..."
T_START=$(date +%s)
rsync $RSYNC_BASE_OPTS \
rsync $RSYNC_BASE_OPTS --delete \
-e "ssh $RSYNC_SSH_OPTS" \
root@"$PBS_IP":"$SRC"/ "$DST"/ 2>&1 | tee -a "$LOG"
T_END=$(date +%s)
@@ -97,10 +97,12 @@ SUMMARY=$(
• Durée : ${DUR}s
• Log : ${LOG}
Horodatage : $(date -Iseconds)
EOF
)
log "Résumé:\n${SUMMARY}"
# (fix) éviter "\n" littéral dans les logs
log "Résumé:"
while IFS= read -r line; do log "$line"; done <<< "$SUMMARY"
send_discord "$SUMMARY" "$LOG"
log "🎉 Terminé."
exit 0