Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 178:00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Tue, 16 Aug 2022 11:51:05 +0200 |
| parents | 9ffbe53dbc35 |
| children | 6c144aca8ac5 |
| files | sbin/fjail |
| diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/sbin/fjail Tue Aug 16 11:44:56 2022 +0200 +++ b/sbin/fjail Tue Aug 16 11:51:05 2022 +0200 @@ -50,6 +50,7 @@ Copy a tree of ZFS datasets with "zfs send -R" and "zfs receive". Note that the destination dataset must not exist already. + -r Copy the datasets with the -Lec options (aka "raw") -u Do not automatically mount received datasets ENVIRONMENT: @@ -255,12 +256,16 @@ command_copy() { # source dataset -- destination dataset local _source _dest - # dynamic ZFS options - local _zfsopts + # dynamic ZFS options -- ZFS copy options + local _zfsopts _zfscopyopts _zfsopts="" - while getopts "u" _opt ; do + _zfscopyopts="" + while getopts "ru" _opt ; do case ${_opt} in + r) + # Use raw datasets + _zfscopyopts="-Lec" u) # do not mount newly created datasets _zfsopts="${_zfsopts} -u" @@ -283,8 +288,8 @@ echo "ERROR: no source dataset given" >&2 return 2 fi - zfs send -R -n -v ${_source} || { echo "ERROR: ZFS operation failed in no-op mode" >&2; return 1; } - zfs send -R "${_source}" | zfs receive ${_zfsopts} "${_dest}" || { echo "ERROR: ZFS operation failed" >&2; return 1; } + zfs send -R ${_zfscopyopts} -n -v "${_source}" || { echo "ERROR: ZFS operation failed in no-op mode" >&2; return 1; } + zfs send -R ${_zfscopyopts} "${_source}" | zfs receive ${_zfsopts} "${_dest}" || { echo "ERROR: ZFS operation failed" >&2; return 1; } }
