是否存在 ZFS 感知差异?

fad*_*bee 5 linux diff zfs snapshot ubuntu

我经常制作 ZFS 卷(包含 AOSP)的快照,进行一些更改(通常在顶部提取 ZIP 文件,或运行脚本),然后运行diff以查看发生了哪些变化。

使用 ZFS 这真的很容易:

diff /mnt/vol /mnt/vol/.zfs/2017-10-18_snapshot

当“vol”包含 63GB 的大部分小文件时,需要很长时间。

ZFS 显然具有有关哪些文件不同的信息,因为快照是写时复制的。

是否有一个 ZFS-aware diff 可以只向 ZFS 询问答案?

use*_*391 4

其实是有的,而且还被命名为zfs diff文档和示例

$ zfs diff tank/home/tim@snap1 tank/home/tim@snap2
M       /tank/home/tim/
+       /tank/home/tim/fileB
Run Code Online (Sandbox Code Playgroud)

您还可以在快照和实时数据集之间进行比较,但只能在相同的数据集和后代中进行比较,并且只能按有效的时间顺序(意味着从旧到新而不是从新到旧,如果一开始不起作用,只需交换参数)。可能的结果是:

M : File or directory has been modified or file or directory link has changed
- : File or directory is present in the older snapshot but not in the more recent snapshot
+ : File or directory is present in the more recent snapshot but not in the older snapshot
R : File or directory has been renamed
Run Code Online (Sandbox Code Playgroud)

要过滤结果并在脚本中使用它们,另请参阅我在 StackOverflow 上的其他答案中的评论中的示例。