A snapshot records a VM's disk (and optionally memory) at a point in time so you can roll back after a bad update or failed experiment. This guide covers KVM snapshots with virsh, the two snapshot styles and the mistakes to avoid.
Before you start
- A KVM host with libvirt and root access.
- For internal snapshots the VM disk must be qcow2. See qcow2 vs raw.
- Optional:
qemu-guest-agentinstalled and running in the guest.
Internal vs external snapshots
| Internal | External | |
|---|---|---|
| Stored | Inside the same qcow2 file | New overlay file; original becomes read-only |
| Revert with virsh | Simple | Supported in newer libvirt; older versions need manual steps |
| Use | Quick rollback points | Live backups, block commit |
Create a snapshot
Internal snapshot with a description:
virsh snapshot-create-as web01 pre-upgrade --description "Before PHP upgrade"Disk-only external snapshot, quiesced through the guest agent so filesystems are consistent:
virsh snapshot-create-as web01 backup1 --disk-only --atomic --quiesceList and inspect snapshots
virsh snapshot-list web01 --treevirsh snapshot-info web01 pre-upgradeRevert to a snapshot
virsh snapshot-revert web01 pre-upgradeEverything written after the snapshot is lost. Shut the VM down first if the snapshot did not include memory.
Delete a snapshot
virsh snapshot-delete web01 pre-upgradeFor external snapshots, merge the overlay back into the base when done, then remove metadata:
virsh blockcommit web01 vda --active --pivot --verboseSnapshots are not backups
- They live on the same storage as the VM; a disk failure loses both.
- Long snapshot chains slow I/O and use more space over time.
- Keep snapshots for hours or days, and take real off-host backups. See website backups explained.
Troubleshooting
- "internal snapshots of a raw disk are not supported": use an external snapshot or convert to qcow2.
- --quiesce fails: install and start
qemu-guest-agentand add the guest agent channel to the VM. - Host disk filling up: delete or commit old snapshots.
Frequently asked questions
Can I snapshot my VPS from a panel?
Many VPS panels offer snapshots or backups; options depend on the provider. Virtualizor users can see Virtualizor backups.
Do snapshots include RAM?
Internal snapshots of a running VM include memory state by default; --disk-only snapshots do not.
How many snapshots should I keep?
As few as possible, ideally one or two short-lived ones.
