Übersicht
Das Tool cv4pve-autosnap ermöglicht es, regelmäßig Snapshots in Proxmox zu erstellen und eine festgelegte Anzahl davon zu behalten.
Installation
cd /tmp/
wget https://github.com/Corsinvest/cv4pve-autosnap/releases/latest/download/cv4pve-autosnap-linux-x64.zip
unzip cv4pve-autosnap-linux-x64.zip
chmod +x cv4pve-autosnap
mv cv4pve-autosnap /usr/local/bin/
Konfiguration
Snapshot-Rolle und Benutzer anlegen
In der Proxmox-GUI unter Datacenter → Permissions → Roles eine neue Rolle mit folgenden Berechtigungen erstellen:
Datastore.AuditVM.AuditVM.Snapshot
Anschließend einen neuen Benutzer anlegen und dieser Rolle zuweisen.
Cron-Job einrichten
Konfigurationsdatei /etc/cron.d/snapshot anlegen:
# Stündliche Snapshots (behalte 2)
0 * * * * root cv4pve-autosnap --host=localhost --username=snapuser@pve --password=geheim snap --vmids=all --label=hourly --keep=2
# Tägliche Snapshots um Mitternacht (behalte 6)
0 0 * * * root cv4pve-autosnap --host=localhost --username=snapuser@pve --password=geheim snap --vmids=all --label=daily --keep=6
# Wöchentliche Snapshots sonntags (behalte 4)
0 0 * * SUN root cv4pve-autosnap --host=localhost --username=snapuser@pve --password=geheim snap --vmids=all --label=weekly --keep=4
# Monatliche Snapshots am 1. des Monats (behalte 2)
0 0 1 * * root cv4pve-autosnap --host=localhost --username=snapuser@pve --password=geheim snap --vmids=all --label=monthly --keep=2
Retention
Der --keep-Parameter bestimmt, wie viele Snapshots jedes Labels behalten werden. Ältere Snapshots werden automatisch gelöscht:
- 2 stündliche Snapshots
- 6 tägliche Snapshots
- 4 wöchentliche Snapshots
- 2 monatliche Snapshots