如何测试两个btrfs快照是否相同?

如何测试两个btrfs快照是否相同?

据我所知,为了确定一个快照是否与另一个快照相同,我们应该检查Received UUID目标快照的 UUID 是否等于源快照的 UUID。

但这一次,这个程序不能应用:

root@aea3:/mnt/zencefil/snapshots/rootfs# btrfs send rootfs.20170705T1334/ | pv | btrfs receive /mnt/aea3/manual-snapshots/                                              
At subvol rootfs.20170705T1334/                                                                                                                                          
At subvol rootfs.20170705T1334                                                                                                                                          
37.8GiB 0:37:27 [17.2MiB/s] [                                                                            
root@aea3:/mnt/zencefil/snapshots/rootfs# btrfs sub show rootfs.20170705T1334/
/mnt/zencefil/snapshots/rootfs/rootfs.20170705T1334
        Name:                   rootfs.20170705T1334
        UUID:                   e66ace1b-3efc-5d40-b3ca-af000110e89d
        Parent UUID:            85bc19f1-9d61-da43-a4be-40c717aee652
        Received UUID:          c6f65496-f21d-c049-b2e2-44007b269dc6
        Creation time:          2017-07-10 12:47:16 +0300
        Subvolume ID:           2561
        Generation:             4331
        Gen at creation:        4327
        Parent ID:              257
        Top level ID:           257
        Flags:                  readonly
        Snapshot(s):
                                snapshots/rootfs/rootfs.20170710T1242
root@aea3:/mnt/zencefil/snapshots/rootfs# btrfs sub show /mnt/aea3/manual-snapshots/rootfs.20170705T1334/
/mnt/aea3/manual-snapshots/rootfs.20170705T1334
        Name:                   rootfs.20170705T1334
        UUID:                   53bc9463-2fe6-9a41-b17d-a0a8dc5e6086
        Parent UUID:            -
        Received UUID:          c6f65496-f21d-c049-b2e2-44007b269dc6
        Creation time:          2017-07-12 10:36:50 +0300
        Subvolume ID:           1832
        Generation:             64698
        Gen at creation:        64627
        Parent ID:              1831
        Top level ID:           1831
        Flags:                  readonly
        Snapshot(s):
root@aea3:/mnt/zencefil/snapshots/rootfs# btrfs --version
btrfs-progs v4.11

但是,当我创建并发送测试快照并将其发送到同一台计算机上的相同驱动器上时,它会按预期工作:

root@aea3:/mnt/zencefil/test# btrfs send mytest1/ | pv | btrfs receive /mnt/aea3/test/
At subvol mytest1/
At subvol mytest1
 540 B 0:00:00 [73.1KiB/s] [                                                                                                                                        ]
root@aea3:/mnt/zencefil/test# btrfs sub show mytest1/
/mnt/zencefil/test/mytest1
        Name:                   mytest1
        UUID:                   3a932406-8a81-5047-9a23-9333564752c2
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2017-07-12 11:41:22 +0300
        Subvolume ID:           2567
        Generation:             4369
        Gen at creation:        4367
        Parent ID:              5
        Top level ID:           5
        Flags:                  readonly
        Snapshot(s):
root@aea3:/mnt/zencefil/test# btrfs sub show /mnt/aea3/test/mytest1/
/mnt/aea3/test/mytest1
        Name:                   mytest1
        UUID:                   98d59473-5a47-7742-bcf7-47262b9cada2
        Parent UUID:            -
        Received UUID:          3a932406-8a81-5047-9a23-9333564752c2
        Creation time:          2017-07-12 11:44:16 +0300
        Subvolume ID:           1844
        Generation:             64738
        Gen at creation:        64737
        Parent ID:              5
        Top level ID:           5
        Flags:                  readonly
        Snapshot(s):

这里缺少的一点是什么?

答案1

在第一种情况下,快照/mnt/zencefil/snapshots/rootfs/rootfs.20170705T1334之前已从其他位置收到。原始 UUID 存储为Received UUID.当再次传输该快照时,这Received UUID也用于副本。

因此,为了确定快照是否与另一个快照相同(即副本),请检查接收到的目标 UUID 是否等于收到源的 UUID(如果存在),或者源的 UUID,否则。

相关内容