Skip to content

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.

  1. 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.zip
    unzip cv4pve-autosnap-linux-$arch.zip
    chmod +x cv4pve-autosnap

    All files are on the latest release page.

  2. Create an API token

    Create a dedicated user and an API token in Proxmox VE, with the privileges the tool needs: see Permissions.

  3. Run cv4pve-autosnap status

    Point the tool at any node:

    cv4pve-autosnap --host=pve01 --api-token='autosnap@pve!snap=<uuid>' --vmid=100 status

    Several nodes, username and password, certificates and options in a file for scheduled runs: see Connection.

  4. 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.

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.

--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=7
ACTION Snap
PVE Version: 8.4.21
VMs: 1000
Label: daily
Keep: 7
State: False
Only running: False
Timeout: 30 sec.
Timestamp format: yyMMddHHmmss
Max % 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: autodaily260929091742
VM execution 00:00:00.0349731
Total execution 00:00:00.2065907

First 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.

# every VM and container of the cluster, keep the last 7 "daily" snapshots of each
cv4pve-autosnap --host=pve01 --api-token='…' --vmid=@all snap --label=daily --keep=7
# what is there now
cv4pve-autosnap --host=pve01 --api-token='…' --vmid=@all status --label=daily

The exit code is 0 when every guest got its snapshot and its old ones removed, 1 when one did not: see Commands.