• No LLMs were harmed in the making of this site.
  • Backup isn't important. Recovery is what matters.
  • No bugs were found in the making of this site; they were just feature requests with better names.
  • This code runs perfectly – the bugs were just user stories that got promoted.
  • We don’t debug; we rely on intentional chaos to surface hidden issues.

PVE, Repliche e Backup

Ultimamente, diciamo dall’aggiornamento di PVE alla versione 7.1, sto avendo alcuni problemi con la replica dei LXC e delle VM.

Purtroppo ho poco tempo per indagare a fondo, ma uno degli effetti è quello di trovare snapshot VZDUMP (quindi prodotti dal backup), pendenti ma che non possono essere eliminati perché alcune repliche dipendono da esso.

Ho pensato di tagliare la testa al toro, utilizzando la funzionalità, ampiamente documentata (si, sono sarcastico), degli hook script (cioè script che vengono richiamati prima e dopo il backup) per disabilitare le repliche prima e riabilitarle dopo il backup. Ecco lo script, da mettere in ogni nodo del cluster:

#!/bin/bash

if [ "$1" == "job-start" ]; then
  #disabilito le schedulazioni delle repliche
  
	for vm in $(pct list| grep -v VMID| awk {'print $1'};qm list | grep -v VMID| awk {'print $1'}) 
	do 
		ids=$(pvesr list | grep $vm| awk {'print $1'})
		for id in $ids
		do
			pvesr disable $id
		done
	done
   
   #attendo che le repliche siano effettivamente ferme
   
	statuses=$(pvesr status | awk {'print $8'} | grep -v State)
	
	running=pippo
	
	until [ $running == false ]
	do
		running=false
		statuses=$(pvesr status | awk {'print $8'} | grep -v State)
		for status in $statuses 
		do 
			if [ $status == "Running" ] || [ $status == "SYNCING" ] 
			then 
				running=true
			fi
		done
	done
  
  
fi

if [ "$1" == "job-end" ]; then
  #abilito le schedulazioni delle repliche
  
   for vm in $(pct list| grep -v VMID| awk {'print $1'};qm list | grep -v VMID| awk {'print $1'}) 
   do 
	 ids=$(pvesr list | grep $vm| awk {'print $1'})
	 for id in $ids
	 do
		pvesr enable $id
	done
   done
fi

exit 0

dopo aver messo lo script da qualche parte e avergli dato i permessi di esecuzione, occorre andare a specificarlo nel file /etc/vzdump.conf.


Leave a Reply

Your email address will not be published. Required fields are marked *