This evening while I was running the system update on one of the guest VMs running on my XCP-ng host, I accidentally rebooted the XCP-ng host. Why? Accident!

The guest VM is very important, it’s running Xen Orchestra for this XCP-ng server. Semi-fortunately, I remember I had a snapshot for this VM. The challenge for me was, how could I restore the VM using that previous snapshot without Xen Orchestra.

After researching for a while, I finally found away thanks to this document [1] provided by XenServer.

The following command list the VM matching xoa1 label (name):

[20:14 xcpng ~]# xe vm-list | grep xoa1 -A2 -B2

uuid ( RO)           : 710d56ec-e6f4-f2a6-63a3-38475c07e583
     name-label ( RW): xoa1_2023-06-16T12:28:35.618Z
    power-state ( RO): halted

--

uuid ( RO)           : 7db193f6-6ad5-5c61-c903-abec6c9666dc
     name-label ( RW): xoa1
    power-state ( RO): halted

List all the snapshots for a particular VM with uuid:

[20:16 xcpng ~]# xe snapshot-list snapshot-of=7db193f6-6ad5-5c61-c903-abec6c9666dc
uuid ( RO)                : 710d56ec-e6f4-f2a6-63a3-38475c07e583
          name-label ( RW): xoa1_2023-06-16T12:28:35.618Z
    name-description ( RW): xoa-ce
    is-vmss-snapshot ( RO): false

Finally, to “revert” the VM back to a snapshot, run:

[20:17 xcpng ~]# xe snapshot-revert snapshot-uuid=710d56ec-e6f4-f2a6-63a3-38475c07e583

Kinda happy that I was able to do this (for the firs time), and super glad that I actually create snapshots of VMs before any changes were made to them.

Reference: