How to Use the Command 'qm snapshot' (with Examples)
The qm snapshot
command is a powerful tool in the Proxmox Virtual Environment (PVE) that enables administrators to create snapshots of virtual machines. Snapshots are point-in-time representations of the state of a machine, allowing for easy backups and rollbacks in case of system failures or other issues. The qm snapshot
command offers flexibility in snapshot creation, supporting various options such as adding descriptions and saving the virtual machine’s state.
Use case 1: Create a Snapshot of a Specific Virtual Machine
Code:
qm snapshot 101 my_first_snapshot
Motivation:
Creating a snapshot for a specific virtual machine is a fundamental use case. This allows administrators to capture the exact state of a virtual machine at a given moment, providing a safeguard before making significant changes to the VM, such as upgrading software or installing new applications. By taking a snapshot beforehand, you can easily revert to this state if anything goes wrong during the update.
Explanation:
qm snapshot
: This is the base command used to create a snapshot of a VM within the Proxmox environment.101
: This is the unique identifier (vm_id
) of the virtual machine for which you want to create a snapshot. Each VM in Proxmox has its own unique ID.my_first_snapshot
: This is the name assigned to the created snapshot. It should be a descriptive name that helps you identify the snapshot’s purpose or timestamp.
Example Output:
When the command is executed successfully, you may see a confirmation message such as:
Snapshot 'my_first_snapshot' of VM 101 created successfully.
Use case 2: Create a Snapshot with a Specific Description
Code:
qm snapshot 102 pre_update_snapshot --description "Snapshot before software update"
Motivation:
Adding a description to a snapshot ensures clarity about the context or reasoning behind the snapshot’s creation. Especially in environments with multiple administrators or complex infrastructures, descriptions provide valuable information for anyone viewing the snapshots later, helping them understand why a particular snapshot was taken and aiding in choosing the correct snapshot for potential rollbacks.
Explanation:
qm snapshot
: Initiates the command to create a new snapshot.102
: Thevm_id
for which the snapshot is intended. This identifier directs the command to the specific virtual machine in the Proxmox system.pre_update_snapshot
: This is the name of the snapshot. Names should be intuitive so they can be easily associated with the task or event they are meant to capture.--description "Snapshot before software update"
: This optional flag provides additional information to the snapshot. The description specifies why the snapshot was created, which, in this example, is to note that it was taken before a software update.
Example Output:
The command execution might result in an output like:
Snapshot 'pre_update_snapshot' with description 'Snapshot before software update' of VM 102 created successfully.
Use case 3: Create a Snapshot Including the VM State
Code:
qm snapshot 103 full_snapshot_with_state --description "Full snapshot with VM state" --vmstate 1
Motivation:
Including the virtual machine’s state in the snapshot is crucial when you need to capture the entire working memory of the VM. This is particularly important for dynamic or heavily-used VMs, where simply capturing disk data isn’t enough. It allows administrators to preserve the precise state of processes and memory at the moment of snapshot creation, enabling comprehensive recovery options and maintaining data consistency.
Explanation:
qm snapshot
: The command to initiate snapshot creation.103
: The unique identifier (vm_id
) specifying the virtual machine for snapshot creation.full_snapshot_with_state
: This is the name assigned to the snapshot.--description "Full snapshot with VM state"
: As with previous examples, this adds a detailed description providing context.--vmstate 1
: This flag indicates that the snapshot should include the VM’s state (its current memory and processor state). The1
here acts as a boolean flag, with1
meaning “true” or “include VM state.”
Example Output:
A successful command will give confirmation such as:
Snapshot 'full_snapshot_with_state' with description 'Full snapshot with VM state' and VM state of VM 103 created successfully.
Conclusion:
The qm snapshot
command serves as an invaluable tool within the Proxmox Virtual Environment, allowing for versatile and comprehensive management of virtual machine states. Whether you want to create a basic snapshot, add descriptive context, or capture the entire VM state, understanding these use cases ensures effective system resilience and operational continuity.