Pages

Friday, May 28, 2010

Accessing ZFS Snapshots From Windows With "Previous Versions"

ZFS Snapshots

Solaris' ZFS snapshots are a great tool that allows us to instantly create a block level snapshot of a ZFS file system. ZFS uses copy-on-write semantics: newly written data is stored on new blocks while blocks containing the older data are retained (when referenced by, for example, a snapshot.) Since, at snapshot creation, data has already been allocated, both snapshot creation time and snapshot required storage (additional to referenced blocks) are almost negligible. Snapshots can be sent (to a file, over the network, etc.) and received on a destination host (as a file or as a ZFS file system.)

Using ZFS snapshots on Solaris and OpenSolaris is dead easy and incredibly flexible: not only you can snapshot a ZFS file systems for Solaris' own use. Since ZFS file systems are easily shared with many protocols such as NFS, CIFS or iSCSI, you can for example take a snapshot of a ZFS volume used as a Mac OS X Time Machine disk (what I call a two-dimensions time machine), or of a file systems shared with CIFS with Windows clients.

Where Are The Snapshots?

Solaris users probably know that snapshot can be accessed using the special .zfs directory on a ZFS file system. But what if you're accessing this filesystems remotely, for example via CIFS? A first approach might be making .zfs directories visible by setting their snapdir property accordingly:

# zfs set snapdir=visible your/zfs/file/system

Although this method perfectly works and may even seems natural to Solaris users, it might seem to lack the required amount of "user friendliness" required by the typical Windows user. Fortunately, thanks to CIFS, there's another solution which is just as easy and that perfectly integrates with the Windows user experience.

Shadow Copy and the Previous Versions Shell Extension

Microsoft introduced a technology called Shadow Copy (a.k.a. Volume Snapshot Service) back in Windows XP SP 2 and Windows Server 2003. Shadow copy is similar to ZFS snapshots in that it takes block-level snapshots of a running file system (although much more limited.) Microsoft also introduced a shell extension, called Previous Versions, that let the user browse through the previous versions of a file that's been shadow copied. With this extension, a new tab in your Windows Explorer's File Properties window, you can browse and restore a previous version of a modified or deleted file. It seems natural, then, to use this extensions to browse through the ZFS snapshots too.

CIFS

That's exactly what the CIFS guys thought while developing this wonderful Solaris service. CIFS is the natural choice for sharing a ZFS file systems with Windows clients. CIFS implements the SMB protocol and it's, moreover, a wonderfully easy service to configure and maintain. Since CIFS exists, I'm not longing for Samba any more. If you mount a CIFS share in a Previous Versions-enabled copy of Windows, you'll automatically get access to ZFS snapshots without the burden of manually accessing .zfs directories.

Conclusion

As you can see in the following screenshot, Solaris ZFS snapshot are visible in the Previous Versions tab:


Conclusions

ZFS, CIFS and Windows Previous Versions are a great team when sharing ZFS file systems to your Windows clients. Windows has got the most usable interface when you need access to your ZFS snapshots. At least once Windows is superior to Mac OS X which has a fancy, usable but pretty basic interface.

5 comments:

  1. hi Grey!

    I'm posting because I am trying to make this exact thing work, and haven't seen anything much newer on the subject since 2008.

    Obviously, you made the magic happen. I was hoping you could give me a little advice, especially, what you put in your smb.conf, anything special in the globals, but most especially, what did you put in the share definitions?

    Mine looks like:

    [homes]
    comment = Shares
    path = /adshare/Users/%D/%U
    valid users = %U
    read only = No
    browseable = Yes
    vfs objects =shadow_copy_zfs
    shadow_copy:sort = desc
    shadow_copy:format = $Y.$m.$d-$H.$M.$S
    shadow_copy:path = /adshare/Users/%D/%U/.zfs/snapshot
    #nfs4:mode = special

    and i take snapshots like:

    zfs snapshot adshare/Users/RIGHT/duder@GMT-`date -u +%Y.%m.%d-%H.%M.%S`

    can you suggest something I might do differently?

    Cool blog, by the way...

    BiggestChops

    ReplyDelete
  2. Hi BiggestChops.
    Thank you very much.

    This entry in particular is describing a built-in characteristics of CIFS. What you're trying to do should be possible with Samba (by means of the shadow_copy_zfs module) but I never tried it: since CIFS is out I just abandoned Samba in Solaris when sharing ZFS file systems.

    I suggest that you try CIFS instead of Samba if you're using a suitable Solaris version. Sharing a directory with CIFS is just as easy as this: http://thegreyblog.blogspot.com/2009/01/windows-interoperability-sharing.html

    Hope this helps,
    Grey

    ReplyDelete
  3. Hi!
    Your post rocks! I was thinking of trying this solution to manage shadow copies for our Windows file server clusters and you give me good hints.
    I'll comment back to tell if I was successfull in making it work!
    Regards
    Carlo

    ReplyDelete
  4. Hi Grey,
    thank you for this post once again. Since last time things have evolved in our lab and we are beta-testing ZFS access through CIFS and comparing with our embedded existing solution.
    Thanks again, nI'll keep you informed if we ever are happy with ZFS performances.
    Carlo
    http://www.happysysadm.com/

    ReplyDelete
  5. Hi Carlo.

    I'm really glad it helped you. I hope to hear about it, I'm sure you'll work out with a viable solution with ZFS.

    Bye,
    Grey

    ReplyDelete