访问“仅差异” ZFS快照

gre*_*reg 2 zfs

有没有办法挂载仅包含特定于快照文件的虚拟分区?我知道隐藏的zfs目录,但是它包含快照时的所有文件。我的目标是使差异备份更快...

提前致谢

格雷格

use*_*391 5

尽管Andrew的建议zfs send是使用差异快照的正确方法,但是如果您只想查看差异并在自己的脚本中或在没有ZFS支持的其他平台上使用差异快照,则还有zfs diff

zfs diff [-FHt] snapshot snapshot|filesystem

Display the difference between a snapshot of a given filesystem
and another snapshot of that filesystem from a later time or
the current contents of the filesystem.  The first column is a
character indicating the type of change, the other columns
indicate pathname, new pathname (in case of rename), change in
link count, and optionally file type and/or change time.

The types of change are:
  -       The path has been removed
  +       The path has been created
  M       The path has been modified
  R       The path has been renamed

-F
    Display an indication of the type of file, in a manner
    similar to the -F option of ls(1).
      B       Block device
      C       Character device
      /       Directory
      >       Door
      |       Named pipe
      @       Symbolic link
      P       Event port
      =       Socket
      F       Regular file
-H
    Give more parsable tab-separated output, without header
    lines and without arrows.
-t
    Display the path's inode change time as the first column of
    output.
Run Code Online (Sandbox Code Playgroud)

请注意,两个数据集的顺序必须是时间顺序的。您可以解析结果列表,并且仅使用您感兴趣的那些文件名。

手册页中的示例输出:

# zfs diff -F tank/test@before tank/test
M       /       /tank/test/
M       F       /tank/test/linked      (+1)
R       F       /tank/test/oldname -> /tank/test/newname
-       F       /tank/test/deleted
+       F       /tank/test/created
M       F       /tank/test/modified
Run Code Online (Sandbox Code Playgroud)

另外,如果您使用Oracle Solaris 11.3,则还可以-r切换递归方式比较所有子数据集。


And*_*nle 2

无法通过“正常”文件访问直接访问差异数据,并且即使您可以获得数据,也无法应用从其中获得的数据。如果只有一两个块发生变化,你怎么能只读取文件中的差异呢?如果您只能读取差异,您怎么知道如何将更改的数据应用到更改的文件?如果您想加快差异备份的速度,那么这种“补丁”式的更新可能会非常慢。

简单的“正常”文件访问不提供执行仅差异备份所需的信息。

要对 ZFS 进行差异备份,请使用增量zfs send ...命令:

zfs send -i pool@snap1 pool@snap2 ...
Run Code Online (Sandbox Code Playgroud)

这就是它的目的,而且确实没有办法做得更快,因为 ZFS 文件系统是从头开始设计的,旨在了解差异。