Snapshot function does not work for Jails !!

Louis2

Contributor
Joined
Sep 7, 2019
Messages
177
Hi,

I am setting up a system which jails. Since I am testing with setup options and scripts to generate Jail content, I was a very good Idea to snapshot the empty base jail. I did snapshot <Pool><iocage><jails><involved Jail>.

The jail is not using any other storage.

So after some tests, I decided to return to a previous state, for further testing. So
- I stopped the Jail
- Went to the snapshot manager and issued a roll-back
- did start the Jail

Eh ......... nothing happens ...... jail content still the same
- I verified via SSH and via the local shell ....
- and did wait some time ...
- and did a restart

...... jail content still the same

I did repeat this test at least three times with the same ^bad^ result.

So either I am making a fallacy .... or there is a severe issue somewhere
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
You need to recursively snapshot everything below <Pool><iocage><jails><involved Jail>. This dataset contains only the jail configuration, i.e. config.json and fstab. The jail dataset with the filesystem proper is <Pool><iocage><jails><involved Jail>/root. There may be more datasets, you need to check with zfs list -r <Pool><iocage><jails><involved Jail>.

HTH,
Patrick
 

Louis2

Contributor
Joined
Sep 7, 2019
Messages
177
Patrick, I do not understand. I did make a snapshot from <Pool><iocage><jails><involved Jail> recursive.
What IMHO imply s all data on all levels below, ^including /root^

I noticed that the snapshot command does show two snapshots ^VirtualMachines/iocage/jails/MyJail^ and ^VirtualMachines/iocage/jails/MyJail/root^ Which is ... strange ... I think

I would also assume that restoring the highest level snapshot, have to include all lower level data. So that if I rollback <Pool><iocage><jails><involved Jail> I automatically rollback <Pool><iocage><jails><involved Jail><root> as well !!

To be sure I opened the host:shell and issued ^zfs list -r <Pool><iocage><jails><involved Jail>^ that command showed me
NAME USED AVAIL REFER MOUNTPOINT
VirtualMachines/iocage/jails/MyJail 66.3M 894G 116K /mnt/VirtualMachines/iocage/jails/MyJail
VirtualMachines/iocage/jails/MyJail/root 66.1M 894G 826M /mnt/VirtualMachines/iocage/jails/MyJail/root

The only thing which is strange tho me is that there are two mount points .... where I would expect one
- if ^root^ is NOT a child of ^MyJail^ than I start to understand this ..... however it is at least weird
- and asymmetrical .. I issued one snapshot .... and reinstalling takes two .... !!??
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
I did make a snapshot from <Pool><iocage><jails><involved Jail> recursive.
You did not write that in your initial post.

I noticed that the snapshot command does show two snapshots ^VirtualMachines/iocage/jails/MyJail^ and ^VirtualMachines/iocage/jails/MyJail/root^ Which is ... strange ... I think
Not strange at all. Each dataset is an independent object in ZFS and may have as few or as many snapshots as you please to create without any connection to any other dataset, child/parent or not.

I would also assume that restoring the highest level snapshot, have to include all lower level data. So that if I rollback <Pool><iocage><jails><involved Jail> I automatically rollback <Pool><iocage><jails><involved Jail><root> as well !!
Did you do that on the shell? In that case, well, it doesn't. There is no recursive rollback command. You need to rollback each dataset individually.

Code:
zfs rollback <yourpool>/iocage/jails/<yourjail>@<yoursnapshot>
zfs rollback <yourpool>/iocage/jails/<yourjail>/root@<yoursnapshot>

Or:
Code:
zfs list -t snap -r <yourpool>/iocage/jails/<yourjail> | awk '/@<yoursnapshot>/ { printf "zfs rollback %s\n", $1 }' | sh

I don't know if the UI has got a recursive rollback option. The command line ZFS tool doesn't.
 

Louis2

Contributor
Joined
Sep 7, 2019
Messages
177
OK quite unexpected behavoir .... but I will test that. No doubt I am going to roll-back some jail soon, since I am building a script to (semi) automatically install e.g. a ^My-FAMP^ stack (reason: among other things the ^FAMP plugin^, is not up to date)
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
The recursive snapshot function is a handy shortcut. For rollback my theory is that the designers decided there were too many edge cases that need to be handled by the admin, anyway. E.g. what should the recursive rollback do, if one of the child datasets does not have a snapshot by name <X>?

What is counter intuitive is the fact that there is a -r flag to zfs rollback. But that does not mean recursive. Checking the man page is left as an exercise to the reader ...
 
Top