[OpenIndiana-discuss] How to let find 'see' .zfs directories
jimklimov at cos.ru
Thu Mar 20 13:01:12 UTC 2014
> On 20/03/2014 04:02, Harry Putnam wrote:
>> I wanted to setup some homeboy snapshot destroys on the basis of mving
>> to all .zfs/snapshot directories and using ls -t, sed, zfs snapshot
>> destroy to
>> get rid of snaps beyond the most recent 8 in the directory
>> So is something like 'zfs -H -t snapshot -o name' the only way to
>> ferret out actual addresses of the snaps?
>> I'd sooner use basic oldschool unix tools if possible
One more approach to use is to parse the output of /bin/df (the GNU df
might produce unwanted multiline output and break scripted parsing) to
find the mountpoints. This lets you discover devices which start without
a slash and don't contain a colon (nfs/cifs mounts) do get local POSIX
ZFS datasets. Alternately you can check all mountpoints for existence
of a "$dir/.zfs/snapshot" to get all mounts backed by a ZFS dataset
(including those mounted from the network) and "cd $dir/.zfs/snapshot \
&& ls -1" to list all snapshot names, or mkdir to create a snapshot
(including over network, as long as your access privileges allow that).
One caveat is that for autofs+nfs you'd first have to access (ls) a
mountpoint to get it mounted and then you'd see if it is a ZFS-backed
submount (or indeed *any* mountpoint and not just a directory at all).
And unlike "zfs list", you don't get to "find" and manage snapshots of
non-mounted datasets at all.
More information about the OpenIndiana-discuss