Install cv4pve-autosnap and take automatic Proxmox VE snapshots
cv4pve-autosnap runs outside the cluster (on your workstation, a management VM or a scheduled job) and talks only to the Proxmox VE REST API on port 8006. Nothing is installed on the nodes.
First run
Section titled “First run”Install cv4pve-autosnap
arch=$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/;s/armv7l/arm/')wget https://github.com/Corsinvest/cv4pve-autosnap/releases/latest/download/cv4pve-autosnap-linux-$arch.zipunzip cv4pve-autosnap-linux-$arch.zipchmod +x cv4pve-autosnapcurl -s https://api.github.com/repos/Corsinvest/cv4pve-autosnap/releases/latest | grep -o "https://[^\"]*-$(dpkg --print-architecture)\.deb" | xargs curl -LOsudo dpkg -i cv4pve-autosnap-*-$(dpkg --print-architecture).debcurl -s https://api.github.com/repos/Corsinvest/cv4pve-autosnap/releases/latest | grep -o "https://[^\"]*-$(rpm --eval %_target_cpu)\.rpm" | xargs curl -LOsudo rpm -i cv4pve-autosnap-*-$(rpm --eval %_target_cpu).rpmyay -S cv4pve-autosnapbrew install corsinvest/tap/cv4pve-autosnapcurl -s https://api.github.com/repos/Corsinvest/cv4pve-autosnap/releases/latest | grep -o "https://[^\"]*-$(uname -m)\.pkg" | xargs curl -LOsudo installer -target / -pkg cv4pve-autosnap-*-$(uname -m).pkgarch=$(uname -m | sed 's/x86_64/x64/')curl -LO https://github.com/Corsinvest/cv4pve-autosnap/releases/latest/download/cv4pve-autosnap-osx-$arch.zipunzip cv4pve-autosnap-osx-$arch.zipchmod +x cv4pve-autosnapwinget install Corsinvest.cv4pve.autosnap$arch = @{ AMD64 = 'x64'; x86 = 'x86'; ARM64 = 'arm64' }[$env:PROCESSOR_ARCHITECTURE]Invoke-WebRequest https://github.com/Corsinvest/cv4pve-autosnap/releases/latest/download/cv4pve-autosnap.exe-win-$arch.zip -OutFile cv4pve-autosnap.zipExpand-Archive cv4pve-autosnap.zip -DestinationPath . -ForceAll files are on the latest release page.
Create an API token
Create a dedicated user and an API token in Proxmox VE, with the privileges the tool needs: see Permissions.
Run
cv4pve-autosnap statusPoint the tool at any node:
cv4pve-autosnap --host=pve01 --api-token='autosnap@pve!snap=<uuid>' --vmid=100 statusSeveral nodes, username and password, certificates and options in a file for scheduled runs: see Connection.
Take the first snapshots
Try the command with
--dry-run, then run it: see Try it first and Take snapshots below.
The API library behind the tool is also on NuGet, as Corsinvest.ProxmoxVE.AutoSnap.Api, for .NET applications that want to take snapshots with the same rules.
Order of the options
Section titled “Order of the options”The connection options, --vmid and the other global options
go before the command; the options of the command go after it:
cv4pve-autosnap --host=pve01 --api-token='…' --vmid=@all --max-parallel=2 snap --label=daily --keep=7# └──────────── global options ──────────────────────────┘ └──── command options ────┘An option in the wrong place stops the tool with Unrecognized command or argument.
Try it first
Section titled “Try it first”--dry-run connects, selects the guests and checks the storages, then prints what it would do without
creating or removing anything:
cv4pve-autosnap --host=pve01 --api-token='…' --vmid=1000 --dry-run snap --label=daily --keep=7ACTION SnapPVE Version: 8.4.21VMs: 1000Label: dailyKeep: 7State: FalseOnly running: FalseTimeout: 30 sec.Timestamp format: yyMMddHHmmssMax % Storage : 95% Storage Type Valid Used % Disk Size Disk Usage pve01/datapool zfspool Ok 20 5.44 TB 1.09 TB pve01/local-zfs zfspool Ok 0 357.11 GB 98.3 KB----- VM 1000 qemu running -----Create snapshot: autodaily260929091742VM execution 00:00:00.0349731Total execution 00:00:00.2065907First the settings of the run, then the storages that hold guest disks on the nodes involved, with their
usage, then one block per guest. Without --dry-run the same command creates the snapshot
autodaily260929091742 and, if VM 1000 already has seven daily snapshots, removes the oldest.
Take snapshots
Section titled “Take snapshots”# every VM and container of the cluster, keep the last 7 "daily" snapshots of eachcv4pve-autosnap --host=pve01 --api-token='…' --vmid=@all snap --label=daily --keep=7
# what is there nowcv4pve-autosnap --host=pve01 --api-token='…' --vmid=@all status --label=dailyThe exit code is 0 when every guest got its snapshot and its old ones removed, 1 when one did not:
see Commands.
- Choosing guests: IDs, names, pools, tags, nodes and exclusions.
- Labels and retention: how snapshots are named, counted and removed.
- Scheduling: run it every hour, day or week with cron or the Task Scheduler.
- Snapshot consistency: the QEMU guest agent and databases.