How to rollback a specific directory in ZFS snapshot?

Solution 1:

To answer the question "Is it possible", the answer is no. ZFS snapshots have no concept of files, folders, or anything else, it is a block level snapshot of the entire filesystem.

You can however browse a snapshot and access individual files, as indicated in duenni's answer, or you can clone a snapshot giving you a second copy of the filesystem without rolling back the first.

Solution 2:

In this case I would go to /tank/home/.zfs/snapshot/snapshot_week_01 and pull out the data you need.

See Displaying and Accessing ZFS Snapshots on Oracle's website for details.

Solution 3:

The answer to the question as asked is no; snapshots are per file system and you can only operate on the whole file system when working with the snapshot. So if you roll back to a previous snapshot, that affects the entire file system.

The way to restore specific files or directories from a ZFS snapshot is to navigate into the snapshot directory and then copy the files out of the snapshot, using something like cp -av snapshotfile /home/louis/myfile.