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?
- 25,409
- 45
- 137
- 203
4 Answers
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.
- 25,409
- 45
- 137
- 203
- 2,299
- 2
- 17
- 22
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.
- 6,779
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.
- 30,336
You can access your snapshot without switching to it via the .zfs directory at the root of your dataset. This directory is hidden from ls -a, but you can still access it:
cd /tank/home/.zfs/snapshot_week_01/
rsync -a louis /tank/home/
As mentioned by @Feuermurmel, using rsync prevents the copying of files that haven't changed. Ideally you'd use zfs send | zfs receive for this in order to skip unchanged blocks, but that's not currently possible as far as I'm aware.
- 291