Skip to main content

Snapshots

A snapshot captures the state of a VM at a point in time: its disks, and optionally its RAM. Snapshots are the base of quick rollbacks ("let me try this upgrade…") and of delta backups.

warning

Snapshots are not backups: they live on the same SR as the VM. If the storage is lost, snapshots are lost with it. For real backups (full, delta, replicated, off-site…), use Xen Orchestra backup.

πŸŽ“ How they work​

XCP-ng disks are copy-on-write: taking a snapshot freezes the current disk state as a read-only parent, and the VM continues writing into a new child disk. This makes snapshot creation almost instant, but it has consequences:

base disksnapshot 1snapshot 2active diskfull datachanges onlychanges onlynew writesreads fall through the chain until the data is foundVM writesdeleting a snapshot merges its changes into its neighbor (coalesce) before space returns
A disk chain after two snapshots Β· the VM writes only into the active leafread-only parentsactive disk
  • Each snapshot extends the disk chain; a long chain slightly degrades I/O performance.
  • Snapshots consume space on the SR (on thick-provisioned SRs like LVM/iSCSI/HBA, a snapshot can reserve up to the full disk size).
  • Deleting a snapshot doesn't free space immediately: the coalesce process has to merge the chain in the background first.

πŸ“Έ Take a snapshot​

Two flavors:

  • Disk-only snapshot: captures the disks. Works on a running or halted VM.
  • Snapshot with RAM (also called checkpoint): additionally saves the VM's memory. Reverting resumes the VM exactly where it was, running. Requires working guest tools and takes longer.

From Xen Orchestra: VM β†’ Snapshots tab β†’ new snapshot (with an option to also snapshot the RAM). With xe:

root@xcp-ng-host β€” Take a snapshot
# xe vm-snapshot vm="my-vm" new-name-label="before-upgrade"
# xe vm-checkpoint vm="my-vm" new-name-label="before-upgrade-with-ram"
tip

In Xen Orchestra you can exclude specific disks from snapshots (and backups) by naming convention: putting [NOSNAP] (snapshots) or [NOBAK] (backups and their snapshots) in the disk's name. Very useful for large scratch/data disks. On XCP-ng 8.3, disk exclusion is supported natively by the snapshot API, which XO uses.

βͺ Revert to a snapshot​

Reverting replaces the VM's current state with the snapshot's state. Everything written since the snapshot is lost.

From Xen Orchestra: Snapshots tab β†’ revert. With xe:

root@xcp-ng-host β€” Revert to a snapshot
# xe snapshot-list snapshot-of=<vm-uuid>
# xe snapshot-revert snapshot-uuid=<snapshot-uuid>

After reverting, the VM is halted (or suspended for a RAM snapshot; resume it to continue exactly where it was). The snapshot itself survives the revert, so you can revert again later.

πŸ—‘οΈ Delete a snapshot​

From Xen Orchestra: Snapshots tab β†’ delete. With xe:

root@xcp-ng-host β€” Delete a snapshot
# xe snapshot-uninstall snapshot-uuid=<snapshot-uuid>

Space is reclaimed asynchronously by the coalesce process: expect a delay (and storage I/O activity) before the SR usage drops. If space never comes back, check that coalesce isn't stuck.

πŸ” Scheduled (rolling) snapshots​

Use Xen Orchestra's Rolling Snapshot backup jobs: take a snapshot of selected VMs on a schedule and keep the N most recent ones. This gives you automatic short-term rollback points at near-zero cost. See the XO backup documentation for details, and remember the warning above: schedule real backups too.

🧰 Other things you can do with a snapshot​

  • Create a template from it (golden image without stopping the source VM).
  • Create a full VM from it: xe snapshot-copy snapshot-uuid=<uuid> new-name-label="restored-vm" (or from Xen Orchestra, "create VM from snapshot").
  • Export it as an XVA file: xe snapshot-export-to-template snapshot-uuid=<uuid> filename=snap.xva (see import and export).