You may have constated that snapshots generated by timf’s ZFS Auto Snapshots for Opensolaris are not Samba friendly.
If you look at the snapshots name, you’ll see they include a colon:
root# zfs list -t snapshot | grep mybook/share NAME USED AVAIL REFER MOUNTPOINT mybook/share@zfs-auto-snap:daily-2009-05-12-00:00 35K - 322M - mybook/share@zfs-auto-snap:daily-2009-05-13-00:00 0 - 6.29G - mybook/share@zfs-auto-snap:daily-2009-05-14-00:00 0 - 6.29G - mybook/share@zfs-auto-snap:weekly-2009-05-15-00:00 0 - 6.29G - mybook/share@zfs-auto-snap:daily-2009-05-15-00:00 0 - 6.29G - mybook/share@zfs-auto-snap:daily-2009-05-16-00:00 79K - 6.29G - mybook/share@zfs-auto-snap:daily-2009-05-17-00:00 7.18M - 16.7G - mybook/share@zfs-auto-snap:daily-2009-05-18-00:00 0 - 16.7G - mybook/share@zfs-auto-snap:daily-2009-05-19-00:00 0 - 16.7G - mybook/share@zfs-auto-snap:daily-2009-05-20-00:00 0 - 16.7G - ...
When exported with Samba, Windows clients will see the snapshots like this:

It’s not even possible to open the snapshot directories from Windows.
How does timf’s ZFS Auto Snapshots work? They are launched by zfssnap user’s crontab:
root# crontab -l zfssnap 0 0 1 1,2,3,4,5,6,7,8,9,10,11,12 * /lib/svc/method/zfs-auto-snapshot svc:/system/filesystem/zfs/auto-snapshot:monthly 0 0 1,8,15,22,29 * * /lib/svc/method/zfs-auto-snapshot svc:/system/filesystem/zfs/auto-snapshot:weekly 0 0 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 * * /lib/svc/method/zfs-auto-snapshot svc:/system/filesystem/zfs/auto-snapshot:daily 0 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * * /lib/svc/method/zfs-auto-snapshot svc:/system/filesystem/zfs/auto-snapshot:hourly 0,15,30,45 * * * * /lib/svc/method/zfs-auto-snapshot svc:/system/filesystem/zfs/auto-snapshot:frequent
The script launched is actually the same as the service method: /lib/svc/method/zfs-auto-snapshot
If we look at it, we can see, among other options, that there is a SEP variable to change the “:” separator character (around line 65):
61
62 # A separator character for date strings, and to delimit
63 # snapshot label names. Needed because apparantly Samba
64 # clients can get confused by colons. Who knew?
65 SEP=":"
66
Change SEP to be for example “_”, and you’ll be able to see and open your snapshots from a Windows client!
Now what happends to all the snapshots created before we change the this? If we leave them with the colon, they won’t be destroyed when their time arrives…
So we need to rename them accordingly to the new separator. This can be done with the following scriptlet:
zfs list -t snapshot -H -o name |
grep "zfs-auto-snap" | grep ":" |
while read NAME
do
NEW="$( echo "${NAME}" | tr ":" "_" )"
echo Renaming ${NAME} ${NEW}
zfs rename ${NAME} ${NEW}
done
Now this is how the snapshots will appear from a Windows client: their names are now displayed correctly, and you can enter any of them to browse the files and directories at the date of the snapshot. Great!





Recent Comments