Samba meets ZFS
By user12625760 on Sep 04, 2006
There has been much progress on the new server at home which I will write up later. Today I'll dig into what I have done to make samba and ZFS play well together. As I mentioned getting Samba running was easy. However there is a bit more that you can do to make ZFS even and Samba even better together.
Why not have zfs take a snapshot whenever you login to the PC? So in addition to the regular snapshots I also get one of the home directory of each user when they login.
Just add this line to the [homes] section in the smb.conf:
root preexec = ksh -c '/usr/sbin/zfs snapshot tank/users/%u@smb$(/tank/local/smbdate)'
Then you need the smbdate script to print a good date. You can't just use the date command directly as Samba expands the % entries before they are passed to date. Hence I wrap it in a script:
#!/bin/ksh -p exec date +%F-%R
This results in snapshots like this each time a user logins on the PC
# zfs list | grep smb tank/users/cjg@smb2006-09-04-22:53 0 - 21.1G - #
At some point a script to clean up the old snapshots will be needed.