Update pbs_self_backup.sh
This commit is contained in:
@@ -6,29 +6,24 @@ export PBS_PASSWORD='XXXxxxxxXXXXXXxxxxxxxxxxxXXXXXXxxxxx'
|
|||||||
|
|
||||||
# 🗂️ Répertoire PBS de la VM 100 (PBS lui-même)
|
# 🗂️ Répertoire PBS de la VM 100 (PBS lui-même)
|
||||||
VM_ID="100"
|
VM_ID="100"
|
||||||
DEST_VM_DIR="/mnt/ssd4to/vm/$VM_ID"
|
|
||||||
|
|
||||||
# 📄 Log
|
# 📝 Log journalier avec horodatage
|
||||||
LOGFILE="/var/log/pbs_self_backup.log"
|
LOGFILE="/var/log/pbs_self_backup-$(date +%F).log"
|
||||||
> "$LOGFILE"
|
> "$LOGFILE"
|
||||||
|
|
||||||
# 📤 Discord Webhook
|
# 📤 Discord Webhook
|
||||||
WEBHOOK="https://discord.com/api/webhooks/XXXxxxxxXXXXXXxxxxxxxxxxxXXXXXXxxxx/XXXxxxxxXXXXXXxxxxxxxxxxxXXXXXXxxxxXXXxxxxxXXXXXXxxxxxxxxxxxXXXXXXxxxx"
|
WEBHOOK="https://discord.com/api/webhooks/XXXxxxxxXXXXXXxxxxxxxxxxxXXXXXXxxxx/XXXxxxxxXXXXXXxxxxxxxxxxxXXXXXXxxxxXXXxxxxxXXXXXXxxxxxxxxxxxXXXXXXxxxx"
|
||||||
|
|
||||||
# 🧾 Début du backup
|
# 🔪 Tuer tout processus figé précédemment
|
||||||
|
pkill -f "proxmox-backup-client backup root.pxar:/" 2>/dev/null
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# 🕓 Horodatage début
|
||||||
START_TIME=$(date "+%a %b %d %T %Z %Y")
|
START_TIME=$(date "+%a %b %d %T %Z %Y")
|
||||||
echo "[$START_TIME] 🔄 Starting backup of PBS (self) to $PBS_REPOSITORY (vm/$VM_ID)" >> "$LOGFILE"
|
echo "[$START_TIME] 🔄 Starting backup of PBS to $PBS_REPOSITORY (vm/$VM_ID)" >> "$LOGFILE"
|
||||||
|
|
||||||
# ✅ S'assure que le fichier owner est correct
|
# 📦 Lancer la sauvegarde PBS root
|
||||||
echo 'backup@pbs!pveclient' > "$DEST_VM_DIR/owner"
|
proxmox-backup-client backup root.pxar:/ \
|
||||||
chown backup:backup "$DEST_VM_DIR/owner"
|
|
||||||
|
|
||||||
# 📝 Création d'un fichier note de contexte
|
|
||||||
NOTEFILE="/tmp/pbs_backup_note.txt"
|
|
||||||
echo "📦 Backup automatique de PBS (VM $VM_ID) – lancé le $START_TIME" > "$NOTEFILE"
|
|
||||||
|
|
||||||
# 📦 Lancer la sauvegarde (incluant la note)
|
|
||||||
proxmox-backup-client backup root.pxar:/ note.txt:$NOTEFILE \
|
|
||||||
--repository "$PBS_REPOSITORY" \
|
--repository "$PBS_REPOSITORY" \
|
||||||
--backup-id "$VM_ID" \
|
--backup-id "$VM_ID" \
|
||||||
--backup-type vm >> "$LOGFILE" 2>&1
|
--backup-type vm >> "$LOGFILE" 2>&1
|
||||||
@@ -42,7 +37,7 @@ else
|
|||||||
echo "[$END_TIME] ❌ PBS self-backup failed (status $STATUS)." >> "$LOGFILE"
|
echo "[$END_TIME] ❌ PBS self-backup failed (status $STATUS)." >> "$LOGFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 📤 Envoi Discord avec pièce jointe
|
# 📤 Notification Discord avec log en pièce jointe
|
||||||
curl -F "payload_json={\"content\":\"📦 Rapport sauvegarde PBS (self-backup vm/$VM_ID)\"}" \
|
curl -F "payload_json={\"content\":\"📦 Rapport sauvegarde PBS (self-backup vm/$VM_ID)\"}" \
|
||||||
-F "file=@$LOGFILE;type=text/plain" \
|
-F "file=@$LOGFILE;type=text/plain" \
|
||||||
"$WEBHOOK"
|
"$WEBHOOK"
|
||||||
|
|||||||
Reference in New Issue
Block a user