How to use the command qm snapshot (with examples)
The qm snapshot
command is used to create virtual machine snapshots in Proxmox Virtual Environment. A snapshot is a read-only copy of a virtual machine’s disk and memory state at a specific point in time. It allows you to save the current state of a virtual machine and revert back to it whenever needed. The qm snapshot
command provides various options to customize the snapshot creation process.
Use case 1: Create a snapshot of a specific virtual machine
Code:
qm snapshot <vm_id> <snapshot_name>
Motivation:
Creating a snapshot of a specific virtual machine allows you to save its current state before making any changes or modifications to it. This provides a safety net that allows you to quickly restore the virtual machine to its previous state if something goes wrong during the modification process.
Explanation:
<vm_id>
: The ID of the virtual machine for which the snapshot needs to be created.<snapshot_name>
: The name of the snapshot.
Example output:
Snapshot 'snapshot_name' created successfully for virtual machine 'vm_id'.
Use case 2: Create a snapshot with a specific description
Code:
qm snapshot <vm_id> <snapshot_name> --description <description>
Motivation:
Creating a snapshot with a specific description allows you to easily document the purpose or reason behind the creation of the snapshot. This can be helpful when managing a large number of snapshots or when collaborating with other team members who may need to understand the context of a snapshot.
Explanation:
<vm_id>
: The ID of the virtual machine for which the snapshot needs to be created.<snapshot_name>
: The name of the snapshot.--description <description>
: The description to be associated with the snapshot.
Example output:
Snapshot 'snapshot_name' created successfully for virtual machine 'vm_id' with description 'description'.
Use case 3: Create a snapshot including the vmstate
Code:
qm snapshot <vm_id> <snapshot_name> --description <description> --vmstate 1
Motivation:
Creating a snapshot including the vmstate allows you to save not only the virtual machine’s disk state but also its memory state. This means that when you revert back to the snapshot, the virtual machine will resume exactly where it left off, including any running processes or active sessions.
Explanation:
<vm_id>
: The ID of the virtual machine for which the snapshot needs to be created.<snapshot_name>
: The name of the snapshot.--description <description>
: The description to be associated with the snapshot.--vmstate 1
: Specifies to include the virtual machine’s memory state in the snapshot.
Example output:
Snapshot 'snapshot_name' created successfully for virtual machine 'vm_id' with description 'description'. The vmstate was included in the snapshot.
Conclusion:
The qm snapshot
command in Proxmox Virtual Environment is a powerful tool for managing virtual machine snapshots. By using different options provided by the command, you can create snapshots with specific names, descriptions, and even include the virtual machine’s memory state. These snapshots serve as a safety net, allowing you to quickly revert back to a known good state if something goes wrong during modifications or to preserve specific virtual machine configurations.