Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff sbin/fzfs @ 429:bbdb1ab0ea00
Implement "-k" option for "fzfs copy-tree" to keep received snapshots
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 22 Sep 2023 09:22:25 +0200 |
| parents | 824e88618376 |
| children | 9c3b1966ba91 |
line wrap: on
line diff
--- a/sbin/fzfs Thu Sep 21 18:42:41 2023 +0200 +++ b/sbin/fzfs Fri Sep 22 09:22:25 2023 +0200 @@ -256,7 +256,7 @@ #: command_copy_tree() { local _ds_source _ds_target - local _opt_mountpoint _opt_mount_noauto _opt_nomount _opt_dry_run + local _opt_mountpoint _opt_mount_noauto _opt_nomount _opt_keep _opt_dry_run local _ds_source_base _ds_source_snapshot _snapshot_suffix local _ds_tree _ds _ds_relname _ds_canmount @@ -265,9 +265,10 @@ _opt_mountpoint="" _opt_mount_noauto="" _opt_nomount="" + _opt_keep="" _opt_dry_run="" - while getopts "AM:nu" _opt ; do + while getopts "AM:knu" _opt ; do case ${_opt} in A) _opt_mount_noauto="-o canmount=noauto" @@ -275,6 +276,9 @@ M) _opt_mountpoint="${OPTARG}" ;; + k) + _opt_keep="yes" + ;; n) _opt_dry_run="-n" ;; @@ -375,12 +379,14 @@ done # Reset to default IFS=$' \t\n' - # Remove received snapshots + # Remove received snapshots by default if [ -n "${_ds_source_snapshot}" ]; then - if [ -z "${_opt_dry_run}" ]; then - zfs destroy -rv "${_ds_target}${_snapshot_suffix}" - else - echo "Would execute: zfs destroy -rv '${_ds_target}${_snapshot_suffix}'" + if [ -z "${_opt_keep}" ]; then + if [ -z "${_opt_dry_run}" ]; then + zfs destroy -rv "${_ds_target}${_snapshot_suffix}" + else + echo "Would execute: zfs destroy -rv '${_ds_target}${_snapshot_suffix}'" + fi fi fi }
