ZFS Equivalent to UFS nodump

Back when I used UFS filesystems, I could exclude selected directories from being dumped by turning their nodump flag on. Now that I've converted to ZFS, I'm wondering if there is an equivalent way to accomplish this with ZFS? That way I could just take a recursive snapshot of zroot and it would exclude those datasets I don't want to snapshot (for obvious reasons) like zroot/usr/obj, zroot/usr/src, zroot/usr/ports, etc. After searching Google and reading through as much ZFS stuff as I could find, I don't see any ZFS property that would provide the same thing.

Thinking out loud, I guess I could take a recursive snapshot on zroot and then immediately destroy the datasets I don't want to snapshot, but this seems inelegant; or I could just snapshot the specific datasets I want. I'll be sending them to an external zpool for backup. However, I like the idea of taking a snapshot of the whole zroot, as this would ensure I've got a snapshot of everything except what I specifically want to exclude. If I snapshot only certain datasets, I'm fearful I might find out too late that I have missed something.

From my reaseach, ZFS on Solaris seemed to have a way to do this through a com.sun:auto-snapshot property that could be set to false for a dataset. I don't see anything like that on FreeBSD.
 
Like you, I don't believe the functionality exists in ZFS on FreeBSD 9.2-RELEASE to exclude specific directories or ZFS file systems from a recursive snapshot.

However, it is possible to structure your ZFS pool in a way that will allow you to achieve the same thing. The crucial point here is that the hierarchy in your ZFS pool can be entirely different from the hierarchy of your file system. The desired file system hierarchy can be created by appropriately setting the mountpoint property(*) on the ZFS filesystems, using a command like # zfs set mountpoint=/tmp tank0/tmp.

Allow me to explain with an example. Let's say you have a single ZFS pool called tank0. You decide you want a separate ZFS filesystem for /usr/home so you can set a quotum to stop your users filling up your pool, but you want this included in your backup snapshot. However, when you take a snapshot, you want to exclude /usr/ports/distfiles, /usr/obj and /tmp.

You could set up your ZFS hierarchy thusly:
Code:
NAME                    MOUNTPOINT
tank0                   none
tank0/ROOT              /
tank0/ROOT/home         /usr/home
tank0/distfiles         /usr/ports/distfiles
tank0/obj               /usr/obj
tank0/tmp               /tmp

When you want to take your backup, you can take a recursive snapshot of tank0/ROOT: # zfs snapshot -r tank0/ROOT@today.

This will generate the following snapshots:
Code:
tank0/ROOT@today
tank0/ROOT/home@today

These snapshots are then ready for zfs send-ing to wherever needed.

However,tank0/distfiles, tank0/obj and tank0/tmp are not descendants of tank0/ROOT, so the command did not generate snapshots of these.

Ad (*): At the risk of making this post overly complicated, note that filesystem mount points are inherited by default based on the ZFS hierarchy. Thus if you have ZFS filesystem tank0/foo and set the mount point to /usr/local/foo, a newly created ZFS filesystem tank0/foo/bar will automatically have the mount point /usr/local/foo/bar. Where possible, I recommend making use of this inheritance rather than explicitly setting the mountpoint property of each ZFS filesystem as it can mean a lot less typing when you want to mount parts of your filesystem somewhere temporarily.

Update : My original example used a structure similar to that suggested by @vermaden in his post Thread 31662 designed for use with sysutils/beadm but I simplified it in order to answer the question rather than unnecessarily complicating by adding boot environments into the mix. Hopefully I was fast enough with my edit that nobody noticed :r
 
Last edited by a moderator:
Back
Top