如果我们 zfs snap -r tank@20220129,所有子文件系统也会获得该快照。
如何将包含所有子文件系统的 tank 单个快照发送到新池(没有快照的历史基础)?
虽然 zfs send -R tank@20220129 将发送所有子 fs,但它也会发送所有快照。
(我们稍后可以删除所有这些快照,但这可能需要大量额外发送才能在完成后删除。)
似乎没有 zfs send -r 功能。
答案1
最后编辑:您说得对,您无法很好地处理递归(请注意克隆!!树中的每个克隆都需要单独制作)我理解断言,即在继承中复制的是函数,而不是继承的当前值,但我很难处理这是最理想的值的用例。我将提出功能请求。 当任何可修改属性从默认值改变时,所有子级都会自动更改为继承。我有一个加密根和 gen key ds,其中有许多非默认的活动子项。父母和孩子应该有一个属性,以便能够选择不获取或传递继承所有或一组属性。然后 zfs send -R -p 将以预期的方式运行。您的案例需要一个上游功能,通常只有单个快照想要递归发送,并且与从递归创建的快照中递归创建克隆相同是一个预期的选项,我很惊讶地发现它不存在。
我非常确定你可以做一个 zfs 克隆或类似下面的操作,而不是我原来的“如果快照出现,zfs 会将它们全部销毁;然后执行 zfs send | zfs recv 克隆,而不执行任何快照。”这是不优雅的、未经研究的和懒惰的,你无论如何都不需要克隆,只需像这样的一个 for 循环
for ds in $(zfs list -Ho name -r rpool); do \
zfs send ${ds}@20220129 | zfs recv -d newpool; done
但是克隆也可以工作,使用新的 zfs snap -r 和 zfs send -R 作为新克隆中的唯一一个快照。但是您无法递归克隆,因此无论如何都需要类似的 for 循环。或者,如果您不介意丢失所有 zfs-history,请将其 rsync 到一个干净的接收池并安装具有所需属性的数据集。
因此,我正在扩展我的解决方案,因为它并不那么容易或安全,而且我很快就会在一个实时但不是关键的系统上执行它。在我的例子中,我还将拆分我的镜像 vdev,并在 zfs recv 上进行一些池和 zfs 属性更改。
Zpool 和 zfs 递归操作可以改进,这一直是一个 bug bear。并且不清楚使用多个 zsys bootfs、zfs-mount-generator、zfs-zed.service 的最佳实践 (在 systemctl 暂停循环之后不会重新启动!)、持久数据集挂载,这些挂载不会反映启动时 zfs-list.cache/pool 的状态!Cananoical 似乎已经完成了对 root 和 zsys 可用性的 zfs 的推动。它并没有结束,只是因为它是一个 ubuntu 安装程序选项。
for zp in rpool bpool vault; do \
zpool trim -w $zp; zpool scrub -w $zp; \
zfs snap -r ${zp}@b4split; \
done
for zp in rpool bpool vault; do \
zpool attach -w $zp /dev/sda /dev/sde; \
zpool attach -w $zp /dev/sdc /dev/sdf; \
zpool split -w $zp ${zp}-offbakup /dev/sdg /dev/sdh; \
zpool initialize -w ${zp}-offbakup; \
zpool scrub -w ${zp}-offbakup; \
zpool export ${zp}-offbakup; \
done; rest
cat << EOF >> /etc/motd
> IMPORTANT NOTE TO SELF. Pool on zfc-receive with encryption, zstd, new dataset struction for boot enivironments \
Out with ubuntu, snapd!!!, grub, ext4, btrfs, lz4, snapd, systemd, docker, x|X* \
> IN like RSYNC void-linux-install, build zfsbootmenu AND s6 from source \
> wayland lxc libvirt pcie passthrough to stripped win11 for mah Civ-6 and Steam
> EOF
for zp in rpool bpool vault; do \
zfs snap -r $zp@pre-b4move; \
zpool set localhost:PROPERTY-orig $(zpool list -Ho PROPERTY $zp); \
zpool checkpoint $zp;
zpool upgrade $zp (!);
done
for ds in $(zfs -Ho name -r rpool bpool vault); do \
echo "record some original properties for reuse - inherited props belong to parent dataset so revert on recv even with send -R or -p"; \
zfs set localhost:[PROPERTY]_orig=$(zfs -Ho [PROPERTY] $ds); \
done
弄清楚如何将 void linux 和 zfsbootmenu 安装到这个 hacker 中,以及在新的 zfs 发送/接收递归之后所有 zsys 和 systemd zfs 自动挂载。拥有一致的继承和 zfs 接收所需的 -o 非常重要。
─# zlsz
bpool/BOOT/garuda com.ubuntu.zsys:last-used 1665060644
bpool/BOOT/kinetic com.ubuntu.zsys:last-used 1664996078
bpool/BOOT/pve30-cli com.ubuntu.zsys:last-used 1664973489
bpool/BOOT/pve30-gnm com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda com.ubuntu.zsys:last-booted-kernel vmlinuz-linux-lts
rpool/ROOT/garuda com.ubuntu.zsys:bootfs yes
rpool/ROOT/garuda/root com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda/root com.ubuntu.zsys:last-booted-kernel vmlinuz-linux-lts
rpool/ROOT/garuda/root com.ubuntu.zsys:bootfs no
rpool/ROOT/garuda/srv com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda/srv com.ubuntu.zsys:last-booted-kernel vmlinuz-linux-lts
rpool/ROOT/garuda/srv com.ubuntu.zsys:bootfs no
rpool/ROOT/garuda/var com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda/var com.ubuntu.zsys:last-booted-kernel vmlinuz-linux-lts
rpool/ROOT/garuda/var com.ubuntu.zsys:bootfs no
rpool/ROOT/garuda/var/cache com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda/var/cache com.ubuntu.zsys:last-booted-kernel vmlinuz-linux-lts
rpool/ROOT/garuda/var/cache com.ubuntu.zsys:bootfs no
rpool/ROOT/garuda/var/lib com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda/var/lib com.ubuntu.zsys:last-booted-kernel vmlinuz-linux-lts
rpool/ROOT/garuda/var/lib com.ubuntu.zsys:bootfs no
rpool/ROOT/garuda/var/log com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda/var/log com.ubuntu.zsys:last-booted-kernel vmlinuz-linux-lts
rpool/ROOT/garuda/var/log com.ubuntu.zsys:bootfs no
rpool/ROOT/garuda/var/tmp com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/garuda/var/tmp com.ubuntu.zsys:last-booted-kernel vmlinuz-linux-lts
rpool/ROOT/garuda/var/tmp com.ubuntu.zsys:bootfs no
rpool/ROOT/kinetic com.ubuntu.zsys:last-used 1664996078
rpool/ROOT/kinetic com.ubuntu.zsys:last-booted-kernel vmlinuz-5.19.0-18-generic
rpool/ROOT/kinetic com.ubuntu.zsys:bootfs yes
rpool/ROOT/pve30-cli com.ubuntu.zsys:last-used 1664973489
rpool/ROOT/pve30-cli com.ubuntu.zsys:last-booted-kernel vmlinuz-5.15.53-1-pve
rpool/ROOT/pve30-cli com.ubuntu.zsys:bootfs yes
rpool/ROOT/pve30-gnm com.ubuntu.zsys:last-used 1665060644
rpool/ROOT/pve30-gnm com.ubuntu.zsys:last-booted-kernel vmlinuz-5.15.60-1-pve
rpool/ROOT/pve30-gnm com.ubuntu.zsys:bootfs yes
rpool/USERDATA/garuda com.ubuntu.zsys:last-used 1665060644
rpool/USERDATA/garuda com.ubuntu.zsys:bootfs-datasets rpool/ROOT/garuda
rpool/USERDATA/kinetic com.ubuntu.zsys:last-used 1664996078
rpool/USERDATA/kinetic com.ubuntu.zsys:bootfs-datasets rpool/ROOT/kinetic
rpool/USERDATA/pve30-cli com.ubuntu.zsys:last-used 1664973489
rpool/USERDATA/pve30-cli com.ubuntu.zsys:bootfs-datasets rpool/ROOT/pve30-cli
rpool/USERDATA/pve30-gnm com.ubuntu.zsys:last-used 1665060644
rpool/USERDATA/pve30-gnm com.ubuntu.zsys:bootfs-datasets rpool/ROOT/pve30-gnm
-
└─# zfs list -o name,used,dedup,secondarycache,sharesmb,acltype,overlay,compression,encryption,canmount,mountpoint,mounted
NAME USED DEDUP SECONDARYCACHE SHARESMB ACLTYPE OVERLAY COMPRESS ENCRYPTION CANMOUNT MOUNTPOINT MOUNTED
bpool 1.94G on metadata off off off lz4 off off /bpool no
bpool/BOOT 1.92G on metadata off off on lz4 off off none no
bpool/BOOT/garuda 250M on metadata off off off zstd-3 off noauto /boot no
bpool/BOOT/kinetic 782M on metadata off off on lz4 off noauto /boot no
bpool/BOOT/pve30-cli 273M on metadata off off on lz4 off noauto /boot no
bpool/BOOT/pve30-gnm 658M on metadata off off on lz4 off noauto /boot no
bpool/grub 5.37M on metadata off off on lz4 off noauto /boot/grub no
rpool 176G off metadata off posix off lz4 off off /rpool no
rpool/LINUX 772M off metadata off posix off lz4 off off / no
rpool/LINUX/opt 765M off metadata off posix off lz4 off noauto /opt no
rpool/LINUX/usr-local 6.95M off metadata off posix on lz4 off noauto /usr/local no
rpool/ROOT 42.4G off metadata off posix off lz4 off noauto /rpool/ROOT no
rpool/ROOT/garuda 19.7G off metadata off posix off zstd-3 off noauto / no
rpool/ROOT/garuda/root 3.56G off metadata off posix off zstd-3 off noauto /root no
rpool/ROOT/garuda/srv 208K off metadata off posix off zstd-3 off noauto /srv no
rpool/ROOT/garuda/var 5.49G off metadata off posix off zstd-3 off off /var no
rpool/ROOT/garuda/var/cache 5.46G off metadata off posix off zstd-3 off noauto /var/cache no
rpool/ROOT/garuda/var/lib 192K off metadata off posix off zstd-3 off off /var/lib no
rpool/ROOT/garuda/var/log 10.1M off metadata off posix off zstd-3 off noauto /var/log no
rpool/ROOT/garuda/var/tmp 15.5M off metadata off posix off zstd-3 off noauto /var/tmp no
rpool/ROOT/kinetic 7.26G off metadata off posix off lz4 off noauto / no
rpool/ROOT/pve30-cli 6.18G off metadata off posix off lz4 off noauto / no
rpool/ROOT/pve30-gnm 9.28G off metadata off posix off lz4 off noauto / no
rpool/USERDATA 13.8G off metadata off posix on lz4 off off none no
rpool/USERDATA/garuda 11.3G off metadata off posix off lz4 off noauto /home no
rpool/USERDATA/kinetic 791M off metadata off posix on lz4 off noauto /home no
rpool/USERDATA/pve30-cli 3.43M off metadata off posix on lz4 off noauto /home no
rpool/USERDATA/pve30-gnm 1.76G off metadata off posix on lz4 off noauto /home no
rpool/data 98.9G off metadata off posix off lz4 off on /data yes
rpool/data/media 4.01G off metadata off posix off lz4 off on /data/media yes
rpool/data/temp 192K off metadata off posix off lz4 off on /data/temp yes
rpool/data/vm-300-disk-0 29.9G off metadata - - - lz4 off - - -
rpool/data/vm-300-disk-1 312K off metadata - - - lz4 off - - -
rpool/data/vm-300-disk-2 128K off metadata - - - lz4 off - - -
rpool/data/zvol 65.0G off metadata off posix off lz4 off on /data/zvol yes
rpool/data/zvol/vm-101-disk-0 3.15M off metadata - - - lz4 off - - -
rpool/data/zvol/vm-101-disk-1 65.0G off metadata - - - lz4 off - - -
rpool/data/zvol/vm-101-disk-2 6.12M off metadata - - - lz4 off - - -
rpool/pve 20.2G off metadata off posix off lz4 off off / no
rpool/pve/var-lib-pve-cluster 912K off metadata off posix on lz4 off noauto /var/lib/pve-cluster no
rpool/pve/var-lib-vz 16.4G off metadata off posix on lz4 off on /var/lib/vz yes
rpool/pve/zfsys 3.73G off metadata off posix off lz4 off on /zfsys yes
vault 759G off all off off off lz4 off off /vault no
vault/devops 306G off all off off off lz4 off off / no
vault/devops/PVE 84.1G off all off off off lz4 off off /var/lib no
vault/devops/PVE/vz 84.1G off all off off off lz4 off on /var/lib/vvz yes
vault/devops/vm 222G off all off off off lz4 off off /vm no
vault/devops/vm/vm-502-disk-0 88K off all - - - lz4 off - - -
vault/devops/vm/vm-502-disk-1 12.7G off all - - - lz4 off - - -
vault/devops/vm/vm-502-disk-2 64K off all - - - lz4 off - - -
vault/devops/vm/vm-510-disk-0 3.08M off all - - - lz4 off - - -
vault/devops/vm/vm-510-disk-1 209G off all - - - lz4 off - - -
vault/devops/vm/vm-510-disk-2 6.07M off all - - - lz4 off - - -
vault/media 453G off all off off off lz4 off off /vault/media no
vault/media/APP 192G off all off off off lz4 off off /share no
vault/media/APP/downloads 15.8G off all off off off lz4 off on /share/downloads yes
vault/media/APP/library_pc 176G off all off off off lz4 off on /share/library_pc yes
vault/media/DOCS 26.6G off all off off off lz4 off off /share no
vault/media/DOCS/personal 26.6G off all off off off lz4 off noauto /share/personal no
vault/media/DOCS/reference 96K off all off off off lz4 off noauto /share/reference no
vault/media/LINUX 1.29G off all off off off lz4 off off /share no
vault/media/LINUX/lxsteam 1.29G off all off off on lz4 off on /home/mike/.local/Steam yes
vault/media/MUSIC 167G off all off off off lz4 off off /share no
vault/media/MUSIC/dj_bylabel 167G off all off off off lz4 off on /share/dj_bylabel yes
vault/media/PHOTO 288K off all off off off lz4 off off /share no
vault/media/PHOTO/albums 96K off all off off off lz4 off noauto /share/albums no
vault/media/PHOTO/public 96K off all off off off lz4 off noauto /share/public no
vault/media/video 66.2G off all off off off lz4 off off /share no
vault/media/video/library 66.2G off all off off off lz4 off on /share/library yes