Reverting snapshots
In this recipe, we are going to create an internal snapshot of a running instance, introduce a change, then restore back to the original instance state using the snapshot.
Getting ready
For this recipe, we are going to need the following:
- A libvirt host with an existing QCOW2 image
- A running KVM instance, using the QCOW2 image
- The QEMU toolset
How to do it...
To revert the state of a KVM instance to an older state, from an existing snapshot, run the following:
- Connect to the KVM instance and create a new file:
root@kvm:~# virsh console kvm1 Connected to domain kvm1 Escape character is ^] root@debian:~# touch SNAPSHOT root@debian:~# root@kvm:~#
- Create an internal snapshot of the virtual machine:
root@kvm:~# virsh snapshot-create kvm1 Domain snapshot 1492802417 created root@kvm:~#
- Get information about the snapshot:
root@kvm:~# virsh snapshot-info kvm1 --snapshotname 1492802417 Name: 1492802417 Domain: kvm1 Current: yes State: running Location: internal Parent: 1492797458 Children...