【问题标题】:Accessing "diff only" ZFS snapshot访问“仅差异”ZFS 快照
【发布时间】:2016-06-08 00:05:14
【问题描述】:

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

提前致谢

格雷格

【问题讨论】:

    标签: zfs


    【解决方案1】:

    虽然 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.
    

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

    手册页的示例输出:

    # 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
    

    此外,如果您使用 Oracle Solaris 11.3,您还可以使用 -r 开关以递归方式区分所有子数据集。

    【讨论】:

    • 嗯,有趣...然后我可以将它提供给 rsync,不是吗?
    • 是的,我建议您使用-H 选项,然后使用awkgrep。示例:zfs diff fs@oldsnap fs@newsnap | awk '/^(R|M|\+).*/{print $2}' 为您提供所有更改的文件(已删除的文件除外)。
    【解决方案2】:

    没有办法直接通过“正常”文件访问来访问差分数据,即使你能得到它也没有办法应用从其中获得的数据。如果仅更改一两个块,您如何仅读取文件中的差异?如果您可以仅读取差异,您怎么知道如何将更改的数据应用到更改的文件中?如果您尝试加速差异备份,那是一种“补丁”风格的更新,可能会非常缓慢。

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

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

    zfs send -i pool@snap1 pool@snap2 ...
    

    这就是它的意义所在,而且真的没有办法更快地做到这一点,因为 ZFS 文件系统是从头开始设计的,以了解这些差异。

    【讨论】:

    • 感谢您的回答。我的想法是 zfs 实际上知道哪些文件已更改,而扫描更改可能需要几个小时(甚至几天)。 zfs send 命令是否会创建仅包含修改后文件的目标?
    • 可能我忘了说我的目标备份主机不是zfs系统,我用rclone到一个普通的文件系统。
    • ZFS 实际上“知道”差异是什么,因此增量zfs send ... 命令将仅发送两个快照之间的差异。您将遇到的问题是访问其中数据的唯一方法是将其用作zfs recv ... 命令的输入。您可以将来自zfs send ... 的输出存储为常规文件,并在需要时使用它来恢复,但如果不这样做,您将无法访问数据。
    猜你喜欢
    • 2018-10-07
    • 2019-01-24
    • 1970-01-01
    • 2017-12-08
    • 1970-01-01
    • 2010-12-30
    • 1970-01-01
    • 2020-09-26
    • 2017-01-30
    相关资源
    最近更新 更多