ZFS 发送单个快照,包括后代文件系统

发布于 2025-01-12 06:23:47 字数 178 浏览 0 评论 0原文

有没有办法发送包括后代文件系统的单个快照?即使快照是使用“-r”创建的,“zfs send”也仅发送顶级文件系统。 “zfs send -R”发送后代文件系统,但包括所有以前的快照,如果灾难恢复池中不需要以前的快照,则出于灾难恢复目的,这会消耗不必要的空间。

猫 /sys/模块/zfs/版本 0.8.3-1ubuntu12.5

Is there a way to send a single snapshot including descendant file systems? 'zfs send' only sends the the top level file system even if the snapshot was created using '-r'. 'zfs send -R' sends the descendant file systems but includes all the previous snapshots, which for disaster recovery purposes consumes unnecessary space if the previous snapshots are not needed in the disaster recovery pool.

cat /sys/module/zfs/version
0.8.3-1ubuntu12.5

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愿与i 2025-01-19 06:23:47

我完全理解你的用例。尽管我通常面临相反的情况,即我有一个远程备份池,我想从中恢复本地系统上的最新快照。

无论如何,虽然你无法直接达到你想要的目的,但你可以达到想要的状态。这个想法是修剪您的恢复集,使其仅包含最新的快照。
首先发送初始快照:

host# zfs snapshot -r tank/data@initial_snapshot
host# zfs send -R tank/data@initial_snapshot | \
 ssh recovery-host zfs recv tank/data

这将发送所有降序文件系统,并将发送 initial_snapshot 以及在其之前创建的所有文件系统。
如果您之前创建了任何快照,则可以删除它们:

recovery-host# zfs list -H -o name -t snapshot tank/data | head -n -1 \
 | xargs -r -n 1 zfs destroy -r -v

然后发送增量更新并进行修剪,

host# zfs snapshot -r tank/data@${LATEST_LOCAL_SNAPSHOT}
host# zfs send -R -i tank/data@${LATEST_REMOTE_SNAPSHOT} \
 tank/data@${LATEST_LOCAL_SNAPSHOT} | ssh recovery-host zfs recv tank/data
recovery-host# zfs list -H -o name -t snapshot tank/data | head -n -1 \
 | xargs -r -n 1 zfs destroy -r -v

假设 LATEST_LOCAL_SNAPSHOTLATEST_REMOTE_SNAPSHOT 已正确设置。

请注意,这是一个最小的无安全带示例。您应该关心您的发送接收是否成功。如果意外达到恢复池没有任何与源匹配的快照的状态,您将无法再发送增量,因此需要重新开始。

I perfectly understand your use case. Although I for one am usually faced with the oppositie situation where I have a remote backup pool from which I want to restore the latest snapshot on a local system.

In any case, while you cannot achieve what you want in a direct way, you can reach the desired state. The idea is to prune your recovery set so that it only has the latest snapshot.
You start by sending an initial snapshot:

host# zfs snapshot -r tank/data@initial_snapshot
host# zfs send -R tank/data@initial_snapshot | \
 ssh recovery-host zfs recv tank/data

This will send all descending file systems, and will send the initial_snapshot and all those created before it.
If you thus had created any snapshots prior, you can delete them:

recovery-host# zfs list -H -o name -t snapshot tank/data | head -n -1 \
 | xargs -r -n 1 zfs destroy -r -v

Then you send incremental updates and prune,

host# zfs snapshot -r tank/data@${LATEST_LOCAL_SNAPSHOT}
host# zfs send -R -i tank/data@${LATEST_REMOTE_SNAPSHOT} \
 tank/data@${LATEST_LOCAL_SNAPSHOT} | ssh recovery-host zfs recv tank/data
recovery-host# zfs list -H -o name -t snapshot tank/data | head -n -1 \
 | xargs -r -n 1 zfs destroy -r -v

assuming that LATEST_LOCAL_SNAPSHOT and LATEST_REMOTE_SNAPSHOT are appropriately set.

Please mind that this is a minimal seatbelt-less example. You should care about whether your send-receives are successful. If accidently reach the state where your recovery pool does not have any snapshots that match your source, you can no longer send increments and will thus need to start anew.

世界如花海般美丽 2025-01-19 06:23:47

不。

如果您想要整个文件系统进行灾难恢复,则需要整个文件系统。

ZFS 快照不是完整的文件系统。它实际上是它与前一个快照之间的区别,并且该链一直延续到所有快照到文件系统的“基本”副本。

您可以发送增量快照,这仅发送差异。根据 Oracle ZFS 文档

...

如果您要将快照流发送到不同的系统,请通过管道
zfs 通过 ssh 命令发送输出。例如:

host1# zfs 发送坦克/dana@snap1 | ssh host2 zfs receive newtank/dana

当您发送完整流时,目标文件系统不得
存在。

您可以使用 zfs send -i 选项发送增量数据。为了
示例:

host1# zfs send -i坦克/dana@snap1坦克/dana@snap2 | ssh host2 zfs receive newtank/dana

请注意,第一个参数 (snap1) 是较早的快照,
第二个参数 (snap2) 是稍后的快照。在这种情况下,
newtank/dana 文件系统必须已存在才能用于增量
获得成功。

第一个 zfs 命令

host1# zfs send tank/dana@snap1 | ssh host2 zfs recv newtank/dana

发送整个文件系统。

这只是发送差异:

host1# zfs send -i tank/dana@snap1 tank/dana@snap2 | ssh host2 zfs recv newtank/dana

然后可以是

host1# zfs send -i tank/dana@snap2 tank/dana@snap3 | ssh host2 zfs recv newtank/dana

No.

If you want the entire filesystem for disaster recovery, you need the entire filesystem.

A ZFS snapshot is not a complete filesystem. It's effectively the difference between it and the previous snapshot, and that chain continues all the way back through all the snapshots to the "base" copy of the filesystem.

You can send incremental snapshots, which only send the differences. Per Oracle ZFS documentation:

...

If you are sending the snapshot stream to a different system, pipe the
zfs send output through the ssh command. For example:

host1# zfs send tank/dana@snap1 | ssh host2 zfs recv newtank/dana

When you send a full stream, the destination file system must not
exist.

You can send incremental data by using the zfs send -i option. For
example:

host1# zfs send -i tank/dana@snap1 tank/dana@snap2 | ssh host2 zfs recv newtank/dana

Note that the first argument (snap1) is the earlier snapshot and the
second argument (snap2) is the later snapshot. In this case, the
newtank/dana file system must already exist for the incremental
receive to be successful.

The first zfs command

host1# zfs send tank/dana@snap1 | ssh host2 zfs recv newtank/dana

Sends the entire filesystem.

This one just sends the differences:

host1# zfs send -i tank/dana@snap1 tank/dana@snap2 | ssh host2 zfs recv newtank/dana

Which can then be followed by

host1# zfs send -i tank/dana@snap2 tank/dana@snap3 | ssh host2 zfs recv newtank/dana
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文