Backup and Restore a running KVM guest

How to backup and restore a running KVM guest on the command line

If you need to update the software:

Backup the VM:

Assuming a guest called “test”, list location of VM:

Export the XML data that defines the VM:

Take the snapshot:

Guest is now running in /tmp/snapshot_test.qcow2

Copy XML and original data file to where you need it.

Pivot back to original:

Restore the VM:

Copy the .qcow2 file into place.

Creating a new vm:

Check it is present:

Start the vm: