LinuxCommandLibrary

qm-snapshot

Create virtual machine snapshots

TLDR

Create a snapshot of a specific virtual machine (name must start with a letter)

$ qm [[sn|snapshot]] [vm_id] [snapshot_name]
copy

Create a snapshot with a specific description
$ qm [[sn|snapshot]] [vm_id] [snapshot_name] --description [description]
copy

Create a snapshot including the vmstate
$ qm [[sn|snapshot]] [vm_id] [snapshot_name] --description [description] --vmstate 1
copy

List snapshots of a VM
$ qm [[lists|listsnapshot]] [100]
copy

Rollback the state of a specific VM to a specified snapshot
$ qm [[ro|rollback]] [vm_id] [snap_name]
copy

SYNOPSIS

qm snapshot <vmid> create <snapname> [OPTIONS]
qm snapshot <vmid> delete <snapname>
qm snapshot <vmid> revert <snapname>
qm snapshot <vmid> list

PARAMETERS

<vmid>
    The unique numeric identifier of the virtual machine to manage.

<snapname>
    A unique alphanumeric name for the snapshot being created, deleted, or reverted to.

--description <string>
    Provides a descriptive text for the snapshot (used with create).

--vmstate <boolean>
    Set to 1 (true) to include the VM's memory and running state in the snapshot (live snapshot). If 0 (false) or omitted, only the disk state is saved. Defaults to 0 (used with create).

--force <boolean>
    Set to 1 (true) to force the operation, for example, to delete a snapshot that is a parent of other snapshots (used with delete).

--storage <string>
    Specifies the storage to save the VM's memory state when creating a live snapshot (with --vmstate 1).

DESCRIPTION

The term "qm-snapshot" typically refers to the functionality accessed via the qm snapshot subcommand within Proxmox VE (PVE). It is not a standalone command but an integral part of the qm command-line utility for managing KVM virtual machines. This powerful tool allows Proxmox administrators to create, delete, revert to, and list snapshots of their VMs. Snapshots capture the disk state and optionally the memory and running state of a VM at a specific point in time. They are crucial for creating restore points, testing system changes, and enabling efficient backup and recovery strategies within a Proxmox VE environment. The underlying snapshot mechanism leverages storage technologies such as ZFS, LVM thin provisioning, or QCOW2 files.

CAVEATS

Snapshots can consume significant disk space, especially if many are chained or if VMs have high disk I/O. Reverting a snapshot discards all changes made to the VM's disk and optionally memory state since the snapshot was taken. Live snapshots (`--vmstate 1`) can be I/O intensive during creation and might briefly impact VM performance. Not all storage types fully support snapshots (e.g., direct-attached storage without LVM-thin or ZFS layers). Deleting snapshots, particularly parent snapshots, might take time as data is merged or blocks are freed. Frequent snapshot creation and deletion, or long snapshot chains, can sometimes lead to performance degradation or complex management.

SNAPSHOT TYPES

Disk-only Snapshots: These snapshots capture only the VM's disk state. For data integrity, the VM should ideally be stopped or paused during creation. If created on a running VM without --vmstate, it briefly pauses the VM to ensure a consistent disk state.
Live Snapshots (with VM state): Created using the --vmstate 1 option, these snapshots capture both the VM's disk state and its current memory/running state. This allows for a VM to be restored to its exact running condition without downtime during the snapshot process. They require additional storage space to save the memory dump.

SNAPSHOT CHAINS AND DELETION

Snapshots form a chain, where each new snapshot references the state of its parent. When reverting to a parent snapshot, any subsequent (newer) snapshots in that branch become unusable or require forced deletion. Deleting a snapshot in the middle of a chain typically involves merging its unique data into the next snapshot in the chain, which can be a time-consuming I/O operation depending on the amount of changed data.

HISTORY

The qm snapshot subcommand has been an essential feature of Proxmox VE since its early versions, providing a robust mechanism for VM state management. Its development has closely tracked the evolution of storage technologies supported by Proxmox, including LVM-thin, ZFS, and QCOW2. The command's design aligns with the broader qm utility's philosophy of offering comprehensive command-line control over virtual machines, ensuring consistency with other VM operations like starting, stopping, and migrating. Its capabilities have expanded to support both disk-only and live (memory-included) snapshots to meet diverse operational needs.

SEE ALSO

qm(1), pct(1), lvcreate(8), zfs(8), qemu-img(1)

Copied to clipboard