comparison sbin/fzfs @ 426:2cd4777821fc

More work on "fzfs copy-tree"
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 21 Sep 2023 09:35:07 +0200
parents a200c18603c9
children 7056e5b7712d
comparison
equal deleted inserted replaced
425:3ebaa936b2b2 426:2cd4777821fc
257 command_copy_tree() { 257 command_copy_tree() {
258 local _ds_source _ds_target 258 local _ds_source _ds_target
259 local _opt_mountpoint _opt_mount_noauto _opt_nomount _opt_dry_run 259 local _opt_mountpoint _opt_mount_noauto _opt_nomount _opt_dry_run
260 260
261 local _ds_source_base _ds_source_snapshot _snapshot_suffix 261 local _ds_source_base _ds_source_snapshot _snapshot_suffix
262 local _ds_tree _ds _ds_relname 262 local _ds_tree _ds _ds_relname _ds_canmount
263 local _rflags
263 264
264 _opt_mountpoint="" 265 _opt_mountpoint=""
265 _opt_mount_noauto="" 266 _opt_mount_noauto=""
266 _opt_nomount="" 267 _opt_nomount=""
267 _opt_dry_run="" 268 _opt_dry_run=""
334 fi 335 fi
335 done 336 done
336 for _ds in ${_ds_tree}; do 337 for _ds in ${_ds_tree}; do
337 # Determine the relative name of the dataset 338 # Determine the relative name of the dataset
338 _ds_relname="${_ds#${_ds_source_base}}" 339 _ds_relname="${_ds#${_ds_source_base}}"
339 echo "REL: $_ds --- $_ds_relname" 340
341 _ds_canmount=$(zfs get -H -o value canmount "${_ds}")
342 echo "REL: $_ds --- $_ds_relname --- $_ds_canmount"
343
344 _rflags=""
345
346 if [ "${_ds_canmount}" = "off" ]; then
347 _rflags="-o canmount=off"
348 else
349 _rflags="${_opt_mount_noauto}"
350 fi
340 351
341 if [ -z "${_ds_relname}" ]; then 352 if [ -z "${_ds_relname}" ]; then
342 # 353 #
343 # Source root to target root 354 # Source root to target root
344 # 355 #
345 if [ -z "${_opt_mountpoint}" ]; then 356 if [ -z "${_opt_mountpoint}" ]; then
357 _rflags="${_rflags} -x mountpoint"
346 else 358 else
359 _rflags="${_rflags} -o mountpoint="'"'"${_opt_mountpoint}"'"'
347 fi 360 fi
348 else 361 else
349 if [ -z "${_opt_mountpoint}" ]; then 362 _rflags="${_rflags} -x mountpoint"
350 else
351 fi
352 fi 363 fi
364 echo "zfs send -Lec -p -v ${_ds}${_ds_source_snapshot} | zfs receive -v $_opt_nomount ${_rflags} ${_ds_target}${_ds_relname}"
353 done 365 done
354 } 366 }
355 367
356 368
357 #: 369 #: