Using Windows Previous Versions to access ZFS Snapshots (July 14, 2009)
- by user12612012
The
Previous Versions tab on the Windows desktop provides a
straightforward, intuitive way for users to view or recover files from
ZFS snapshots. ZFS snapshots are read-only,
point-in-time instances of a ZFS dataset, based on the same
copy-on-write transactional model used throughout ZFS. ZFS snapshots
can be used to recover deleted files or previous versions of files and they are space efficient because unchanged data is shared between the file system and its snapshots. Snapshots are available locally via the .zfs/snapshot directory and remotely via Previous Versions on the Windows desktop.
Shadow
Copies for Shared Folders was introduced with Windows Server 2003 but
subsequently renamed to Previous Versions with the release of Windows
Vista and Windows Server 2008. Windows shadow copies, or snapshots, are
based on the Volume Snapshot Service (VSS) and, as the [Shared Folders part of the]
name implies, are accessible to clients via SMB shares, which is good
news when using the Solaris CIFS Service. And the nice thing is that no
additional configuration is required - it "just works".
On
Windows clients, snapshots are accessible via the Previous Versions tab
in Windows Explorer using the Shadow Copy client, which is available by
default on Windows XP SP2 and later. For Windows 2000 and pre-SP2
Windows XP, the client software is available for download from
Microsoft: Shadow Copies for Shared Folders Client.
Assuming that we already have a shared ZFS dataset, we can create ZFS snapshots and view them from a Windows client.
zfs snapshot tank/home/administrator@snap101zfs snapshot tank/home/administrator@snap102
To
view the snapshots on Windows, map the dataset on the client then right
click on a folder or file and select Previous Versions. Note that
Windows will only display previous versions of objects that differ from
the originals. So you may have to modify files after creating a
snapshot in order to see previous versions of those files.
The
screenshot above shows various snapshots in the Previous Versions
window, created at different times. On the left panel, the .zfs folder
is visible, illustrating that this is a ZFS share. The .zfs setting can
be toggled as desired, it makes no difference when using previous
versions. To make the .zfs folder visible:
zfs set snapdir=visible tank/home/administrator
To hide the .zfs folder:
zfs set snapdir=hidden tank/home/administrator
The
following screenshot shows the Previous Versions panel when a file has
been selected. In this case the user is prompted to view, copy or
restore the file from one of the available snapshots.
As
can be seen from the screenshots above, the Previous Versions window
doesn't display snapshot names: snapshots are listed by snapshot
creation time, sorted in time order from most recent to oldest. There's
nothing we can do about this, it's the way that the interface works.
Perhaps one point of note, to avoid confusion, is that the ZFS snapshot
creation time isnot the same as the root directory
creation timestamp. In ZFS, all object attributes in the original
dataset are preserved when a snapshot is taken, including the creation
time of the root directory. Thus the root directory creation timestamp
is the time that the directory was created in the original dataset.
# ls -d% all /home/administrator timestamp: atime Mar 19 15:40:23 2009 timestamp: ctime Mar 19 15:40:58 2009 timestamp: mtime Mar 19 15:40:58 2009 timestamp: crtime Mar 19 15:18:34 2009
# ls -d% all /home/administrator/.zfs/snapshot/snap101 timestamp: atime Mar 19 15:40:23 2009 timestamp: ctime Mar 19 15:40:58 2009 timestamp: mtime Mar 19 15:40:58 2009 timestamp: crtime Mar 19 15:18:34 2009
The snapshot creation time can be obtained using the zfs command as shown below.
# zfs get all tank/home/administrator@snap101NAME PROPERTY VALUEtank/home/administrator@snap101 type snapshottank/home/administrator@snap101 creation Mon Mar 23 18:21 2009
In this example, the dataset was created on March 19th and the snapshot was created on March 23rd.
In
conclusion, Shadow Copies for Shared Folders provides a straightforward
way for users to view or recover files from ZFS snapshots. The Windows
desktop provides an easy to use, intuitive GUI and no configuration is
required to use or access previous versions of files or folders.
REFERENCES FOR MORE INFORMATION
ZFS
ZFS Learning Center
Introduction to Shadow Copies of Shared Folders
Shadow Copies for Shared Folders Client