Linux VPS

KVM snapshots with virsh: create, revert and delete

Create, list, revert and delete KVM VM snapshots with virsh, understand internal vs external snapshots, add the guest agent for consistency, and why snapshots are not backups.

IntermediateKVM hosts2 min read

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-agent installed and running in the guest.

Internal vs external snapshots

InternalExternal
StoredInside the same qcow2 fileNew overlay file; original becomes read-only
Revert with virshSimpleSupported in newer libvirt; older versions need manual steps
UseQuick rollback pointsLive 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 --quiesce

List and inspect snapshots

virsh snapshot-list web01 --tree
virsh snapshot-info web01 pre-upgrade

Revert to a snapshot

virsh snapshot-revert web01 pre-upgrade

Everything 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-upgrade

For external snapshots, merge the overlay back into the base when done, then remove metadata:

virsh blockcommit web01 vda --active --pivot --verbose

Snapshots 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-agent and 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.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.