10

Is it possible to rollback to a certain directory within a snapshot? For example, given the snapshot tank/home@snapshot_week_01 can I rollback to something like tank/home/louis@snapshot_week_01 without rolling back all of the other files directories within tank/home?

3 Answers 3

5

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.

18
+50

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.

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.

4
  • Many thanks! I didn't really understand duenni's answer until reading yours and @dasdfdsaq's. But looks like yours was a tiny bit later! Aug 14, 2015 at 15:26
  • @Louis You're welcome; I'm glad I was able to help. (And while it's certainly your choice which answer to accept, you shouldn't feel pressured into accepting the answer that came first. Instead, you should accept the one that you found most helpful to you.)
    – user
    Aug 14, 2015 at 18:22
  • P.S. With a properly configured Samba setup on top of ZFS on Linux, you can also right click on a folder from a Windows client and use the "Previous versions" functionality
    – qasdfdsaq
    Aug 14, 2015 at 23:40
  • I have come accustomed to using rsync -a for this use case. If only a few files in a directory have changed since the snapshot, this prevents from copying more data than necessary. Deleting and re-creating a file with the same content will allocate additional storage. Jan 31, 2020 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .