Il y a 389 articles et 19 utilisateurs inscrits (ce bandeau est défini dans MediaWiki:Sitenotice)

Sauvegarde de l’hôte Proxmox beotos3 vers PBS

De AJLSM
Aller à la navigation Aller à la recherche

Sauvegarde de l’hôte Proxmox beotos3 vers PBS

[modifier | modifier le wikicode]

Mettre en place la sauvegarde de la configuration système du serveur Proxmox beotos3 dans Proxmox Backup Server (PBS), en complément de la sauvegarde des machines virtuelles.

---

  • Serveur Proxmox : beotos3
  • Serveur PBS : pbs4
  • Datastore : pbs-saturne

Les VM sont sauvegardées via Proxmox VE. La configuration de l’hôte est sauvegardée via proxmox-backup-client.

---

Authentification PBS

[modifier | modifier le wikicode]
  • Utilisateur : beotos3@pbs
  • Token : pbs
  • Rôles : DatastoreBackup, DatastoreAudit
  • Chemin : /datastore/pbs-saturne

Le secret du token est stocké dans :

/root/.pbs_token_beotos3

Permissions :

chmod 600 /root/.pbs_token_beotos3

---

Création sur PBS

[modifier | modifier le wikicode]

Sur pbs4 :

proxmox-backup-manager user create beotos3@pbs
proxmox-backup-manager user generate-token beotos3@pbs pbs

proxmox-backup-manager acl update /datastore/pbs-saturne DatastoreBackup --auth-id 'beotos3@pbs'
proxmox-backup-manager acl update /datastore/pbs-saturne DatastoreAudit --auth-id 'beotos3@pbs'
proxmox-backup-manager acl update /datastore/pbs-saturne DatastoreBackup --auth-id 'beotos3@pbs!pbs'
proxmox-backup-manager acl update /datastore/pbs-saturne DatastoreAudit --auth-id 'beotos3@pbs!pbs'

---

Script de sauvegarde

[modifier | modifier le wikicode]

Fichier : /usr/local/sbin/backup_pbs_beotos3.sh

#!/usr/bin/env bash
set -euo pipefail

export PBS_PASSWORD_FILE="/root/.pbs_token_beotos3"
export PBS_FINGERPRINT="79:e2:df:a6:33:56:1b:22:63:b3:31:a4:09:63:de:c4:50:e3:eb:d5:87:a0:14:f0:c8:9c:fa:ed:df:b0:1a:39"
export PBS_HOSTNAME="beotos3"

REPO='beotos3@pbs!pbs@pbs4.ajlsm.com:pbs-saturne'

LOG_DIR="/var/log/beotos3"
LOG_FILE="${LOG_DIR}/backup_pbs.log"
LOCK_FILE="/var/run/backup_pbs_beotos3.lock"

mkdir -p "${LOG_DIR}"

exec 9>"${LOCK_FILE}"
flock -n 9 || exit 1

log() {
  echo "[$(date '+%F %T')] $*" | tee -a "${LOG_FILE}"
}

log "Début backup PBS beotos3"

if proxmox-backup-client backup \
  etc.pxar:/etc \
  pve.pxar:/etc/pve \
  root.pxar:/root \
  usr_local.pxar:/usr/local \
  pve_cluster_lib.pxar:/var/lib/pve-cluster \
  logs_config.pxar:/var/log \
  --repository "${REPO}" >> "${LOG_FILE}" 2>&1
then
  log "Fin backup PBS beotos3 : OK"
else
  RC=$?
  log "Fin backup PBS beotos3 : ERREUR code ${RC}"
  exit "${RC}"
fi

Permissions :

chmod 700 /usr/local/sbin/backup_pbs_beotos3.sh

---

Préparation des logs

[modifier | modifier le wikicode]
mkdir -p /var/log/beotos3

---

Fichier : /etc/cron.d/backup_beotos3

15 22 * * * root /usr/local/sbin/backup_pbs_beotos3.sh

---

mkdir -p /var/log/beotos3
nohup /usr/local/sbin/backup_pbs_beotos3.sh > /var/log/beotos3/nohup_backup.log 2>&1 &

Suivi :

tail -f /var/log/beotos3/backup_pbs.log

---

export PBS_PASSWORD_FILE=/root/.pbs_token_beotos3
export PBS_FINGERPRINT='79:e2:df:a6:33:56:1b:22:63:b3:31:a4:09:63:de:c4:50:e3:eb:d5:87:a0:14:f0:c8:9c:fa:ed:df:b0:1a:39'

proxmox-backup-client snapshots --repository 'beotos3@pbs!pbs@pbs4.ajlsm.com:pbs-saturne'

Contenu sauvegardé

[modifier | modifier le wikicode]
  • /etc : configuration système
  • /etc/pve : configuration Proxmox (VM, cluster)
  • /root : scripts et clés
  • /usr/local : outils spécifiques
  • /var/lib/pve-cluster : base cluster Proxmox
  • /var/log : logs système

---

Procédure de restauration après crash

[modifier | modifier le wikicode]

Étape 1 : Réinstallation

[modifier | modifier le wikicode]
  • Installer Proxmox VE
  • Conserver le même hostname : beotos3
  • Conserver la même configuration IP

---

Étape 2 : Installer le client PBS

[modifier | modifier le wikicode]
apt update
apt install proxmox-backup-client

---

Étape 3 : Restaurer la configuration

[modifier | modifier le wikicode]

Recréer le fichier contenant le token :

cat > /root/.pbs_token_beotos3
chmod 600 /root/.pbs_token_beotos3

Restaurer les fichiers principaux :

export PBS_PASSWORD_FILE=/root/.pbs_token_beotos3
export PBS_FINGERPRINT='79:e2:df:a6:33:56:1b:22:63:b3:31:a4:09:63:de:c4:50:e3:eb:d5:87:a0:14:f0:c8:9c:fa:ed:df:b0:1a:39'

proxmox-backup-client restore host/beotos3/latest etc.pxar /etc
proxmox-backup-client restore host/beotos3/latest pve.pxar /etc/pve

---

Étape 4 : Redémarrer les services Proxmox

[modifier | modifier le wikicode]
systemctl restart pve-cluster
systemctl restart pvedaemon

---

Étape 5 : Vérification

[modifier | modifier le wikicode]
  • Accès à l’interface web Proxmox
  • Vérification de la configuration réseau
  • Vérification de la présence des VM

---

Étape 6 : Restauration complémentaire

[modifier | modifier le wikicode]

Si nécessaire, restaurer d’autres éléments :

proxmox-backup-client restore host/beotos3/latest root.pxar /root
proxmox-backup-client restore host/beotos3/latest usr_local.pxar /usr/local
proxmox-backup-client restore host/beotos3/latest pve_cluster_lib.pxar /var/lib/pve-cluster

---

Étape 7 : Restauration des VM

[modifier | modifier le wikicode]
qmrestore <backup> <vmid>

---

Plan de reprise (PRA)

[modifier | modifier le wikicode]

Ordre :

  1. Réinstallation Proxmox
  2. Restauration /etc et /etc/pve
  3. Redémarrage des services Proxmox
  4. Vérification réseau et accès
  5. Restauration des VM critiques
  6. Restauration complète

---

  • Réinstallation : 15 min
  • Restauration configuration : 5 min
  • Restauration VM : 15 à 30 min

Temps total : environ 1 heure

---

Points de vigilance

[modifier | modifier le wikicode]
  • /etc/pve est un système de fichiers spécial (pmxcfs)
  • Toujours utiliser proxmox-backup-client pour restaurer
  • Le hostname doit être strictement identique (beotos3)
  • Vérifier le réseau avant restauration des VM
  • Restaurer /etc avant /etc/pve