lxc allow you to take snapshot, restore snapshot of a container.
Here we create a snapshot, then delete the /etc folder from the container. Now the container is useless. Restore the container from snapshot to get it work again.
root@UNUSED:~# lxc snapshot my-vm-2 my-vm-2-snap1
root@UNUSED:~# lxc exec my-vm-2 -- rm -rf /etc
root@UNUSED:~# lxc exec my-vm-2 -- bash
I have no name!@my-vm-2:~# ls -l / | grep etc
I have no name!@my-vm-2:~# exit
root@UNUSED:~# lxc restore my-vm-2 my-vm-2-snap1
root@UNUSED:~# lxc exec my-vm-2 -- bash
root@my-vm-2:~# ls -l / | grep etc
drwxr-xr-x 89 root root 4096 Aug 27 07:06 etc
root@my-vm-2:~# exit
root@UNUSED:~#
To list all snapshots of a container, run
lxc info container-name
To delete a snapshot, run
lxc delete container-name/snapshot-name
Container snapshots are stored in folder
/var/snap/lxd/common/lxd/storage-pools/default/containers-snapshots/
Leave a Reply