How to use snapshot to recover a deleted VM?

endnot

Dabbler
Joined
Feb 6, 2019
Messages
33
A few days ago, I deleted a Ubuntu vm built the using the GUI, I want to recover it from a periodic snapshot.

I noticed that my datasets includes a FILESYSTEM dataset named Ubuntu and it contains several VOLUMES. I can browse to the FILESYSTEM dataset and it contains the .iso used to create the vm. Eventhough the VM has been deleted I have several VOLUMES in the FILESYSTEM reporting using ~13.5GB each.

I have cloned a few snapshots that have added a VOLUME dateset to my pool but I do not know how to use it to see if it is my deleted VM.

How do I recover a VM?

TIA.
 

artlessknave

Wizard
Joined
Oct 29, 2016
Messages
1,506
there should be no need to clone anything if you haven't deleted the underlying storage, just recreate the VM and its config.

create VM
give it the same hardware (best guess *shrugs*)
create virtual disks for each zvol it had (easier if there was only 1)
go into each vdisk and point them at the zvols, trying to get the boot disk in the correct place.
if the first zvol you try doesn't boot......try, try again, and see if any of them do.

alternatively, if you were to restore a backup of the config from just before you delete the VM, it might be there. (you have hourly config backups...right? right?)
I think more specifics of what is present would be needed for much more, perhaps something like:
zfs list | grep tank/Ubuntu or zfs list -t all | grep tank/Ubuntu
unsure why you have an iso in the same place as the zvol, but w/e, not important.

i see you have your hardware sig (yay!), but OS version is very good to include as well, either to the sig or when posting a new thread.
 
Last edited:

endnot

Dabbler
Joined
Feb 6, 2019
Messages
33
there should be no need to clone anything if you haven't deleted the underlying storage, just recreate the VM and its config.
i see you have your hardware sig (yay!), but OS version is very good to include as well, either to the sig or when posting a new thread.
Thanks! Your response was very helpful. While none of the zvols would boot, I learned a bit more how TrueNAS Core 12-U8 VMs work.

I have daily snapshots of my entire pool going back 3weeks, but I think that is different from your reference to "hourly config backups.". Would a "config backup" be made using the VM-ware snapshots or are you refering to actual rsysnc type backups?

All of the snapshots for these VOLUMES are of 0B size. Which I assume indicates nothing has changed in the source during the past 3 weeks and once I delete that VOLUME they will be wiped out also.

I did a test with another VM where were I deleted it and its data - the VOLUME and all of the related snapshots are GONE. There is nothing to recover via snapshot. So, when I deleted the Ubuntu VM, it deleted the zvol and related snapshots instantly. I am not sure what these other zvols are for but I think I will delete them.
 

artlessknave

Wizard
Joined
Oct 29, 2016
Messages
1,506
no, a config backup is made from system, general, save config. it's your system settings backup. install the OS from scratch and load that file and your system is restored. you can script it by copying /data/freenas-v1.db somewhere, like to another server, or maybe "the cloud". there is no automatic backup that I know of, but if you copy it to a dataset, you can replicate that dataset somewhere.

as you have noticed, snapshots are not backups. if you delete the dataset, then yes, there would be no snapshots, no dataset, nothing, unless you had backups replicated somewhere else (another server, "the cloud", tape, etc).
what that "ubuntu" dataset you found it, i dunno.

you keep using "VOLUME" but I am not clear what you mean by that. this VOLUME? if so, that's a zvol.
1645751492849.png


All of the snapshots for these VOLUMES are of 0B size. Which I assume indicates nothing has changed in the source during the past 3 weeks and once I delete that VOLUME they will be wiped out also.
yes. the zvols function like a dataset, except that they are block devices instead of filesystems you can access.
 

endnot

Dabbler
Joined
Feb 6, 2019
Messages
33
Thank you again for answering my questions I really appreciate the help. While I have always saved my config when updating/grading but never really thought about how to use it should have something gone wrong. I am very satisfied with TrueNAS as a NAS, but I have not had great success using jails/vms.
I recently got a new workstation for experimenting; learning the nuances of OSs, filesystems, networking and interesting applications using VMs and Containers. Once I get it setup the way I want it I plan to experiment with Truenas so that I can better understand it.
 

artlessknave

Wizard
Joined
Oct 29, 2016
Messages
1,506
something gone wrong
one of the important parts of backups is ensuring you have a way to actually use those backups, and, ideally, occasionally testing that the backups themselves actually worked
success using jails/vms.
bhyve and jails are often ... not amazing. it's one of the reasons TrueNAS scale exists, because scale enables docker and kvm, both mature subsystems with possibly more devs *each* than all of freebsd....
 
Top