Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/fjail @ 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 |
comparison
equal
deleted
inserted
replaced
| 177:9ffbe53dbc35 | 178:00fbf2b4b44f |
|---|---|
| 48 copy SOURCE-DATASET DEST-DATASET | 48 copy SOURCE-DATASET DEST-DATASET |
| 49 | 49 |
| 50 Copy a tree of ZFS datasets with "zfs send -R" and "zfs receive". | 50 Copy a tree of ZFS datasets with "zfs send -R" and "zfs receive". |
| 51 Note that the destination dataset must not exist already. | 51 Note that the destination dataset must not exist already. |
| 52 | 52 |
| 53 -r Copy the datasets with the -Lec options (aka "raw") | |
| 53 -u Do not automatically mount received datasets | 54 -u Do not automatically mount received datasets |
| 54 | 55 |
| 55 ENVIRONMENT: | 56 ENVIRONMENT: |
| 56 | 57 |
| 57 All environment variables that affect "zfs" are effective also. | 58 All environment variables that affect "zfs" are effective also. |
| 253 # command_copy source-dataset destination-dataset | 254 # command_copy source-dataset destination-dataset |
| 254 # | 255 # |
| 255 command_copy() { | 256 command_copy() { |
| 256 # source dataset -- destination dataset | 257 # source dataset -- destination dataset |
| 257 local _source _dest | 258 local _source _dest |
| 258 # dynamic ZFS options | 259 # dynamic ZFS options -- ZFS copy options |
| 259 local _zfsopts | 260 local _zfsopts _zfscopyopts |
| 260 | 261 |
| 261 _zfsopts="" | 262 _zfsopts="" |
| 262 while getopts "u" _opt ; do | 263 _zfscopyopts="" |
| 264 while getopts "ru" _opt ; do | |
| 263 case ${_opt} in | 265 case ${_opt} in |
| 266 r) | |
| 267 # Use raw datasets | |
| 268 _zfscopyopts="-Lec" | |
| 264 u) | 269 u) |
| 265 # do not mount newly created datasets | 270 # do not mount newly created datasets |
| 266 _zfsopts="${_zfsopts} -u" | 271 _zfsopts="${_zfsopts} -u" |
| 267 ;; | 272 ;; |
| 268 \?|:) | 273 \?|:) |
| 281 _dest="$2" | 286 _dest="$2" |
| 282 if [ -z "${_dest}" ]; then | 287 if [ -z "${_dest}" ]; then |
| 283 echo "ERROR: no source dataset given" >&2 | 288 echo "ERROR: no source dataset given" >&2 |
| 284 return 2 | 289 return 2 |
| 285 fi | 290 fi |
| 286 zfs send -R -n -v ${_source} || { echo "ERROR: ZFS operation failed in no-op mode" >&2; return 1; } | 291 zfs send -R ${_zfscopyopts} -n -v "${_source}" || { echo "ERROR: ZFS operation failed in no-op mode" >&2; return 1; } |
| 287 zfs send -R "${_source}" | zfs receive ${_zfsopts} "${_dest}" || { echo "ERROR: ZFS operation failed" >&2; return 1; } | 292 zfs send -R ${_zfscopyopts} "${_source}" | zfs receive ${_zfsopts} "${_dest}" || { echo "ERROR: ZFS operation failed" >&2; return 1; } |
| 288 } | 293 } |
| 289 | 294 |
| 290 | 295 |
| 291 # | 296 # |
| 292 # "privs" -- adjust privileges | 297 # "privs" -- adjust privileges |
