UI exit fixes
This commit is contained in:
@@ -70,7 +70,7 @@ On a terminal (not with `--dry-run`), each filesystem shows a live progress bloc
|
|||||||
```
|
```
|
||||||
|
|
||||||
The overall bar is weighted by each filesystem's logical size. Output that is
|
The overall bar is weighted by each filesystem's logical size. Output that is
|
||||||
not a terminal falls back to plain output.
|
not a terminal falls back to plain output. Pass `--no-ui` to force plain output.
|
||||||
|
|
||||||
Use a non-standard SSH key or port when needed:
|
Use a non-standard SSH key or port when needed:
|
||||||
|
|
||||||
|
|||||||
+17
-2
@@ -20,6 +20,7 @@ Options:
|
|||||||
-i, --identity-file FILE SSH private key to use.
|
-i, --identity-file FILE SSH private key to use.
|
||||||
-p, --ssh-port PORT SSH port to use.
|
-p, --ssh-port PORT SSH port to use.
|
||||||
--destroy-source-snapshots Destroy each local migration snapshot after its successful receive.
|
--destroy-source-snapshots Destroy each local migration snapshot after its successful receive.
|
||||||
|
--no-ui Disable the live progress display; print plain output.
|
||||||
-h, --help Show this help.
|
-h, --help Show this help.
|
||||||
|
|
||||||
SSH must use key or agent authentication; password prompts are disabled. The
|
SSH must use key or agent authentication; password prompts are disabled. The
|
||||||
@@ -35,6 +36,7 @@ die() {
|
|||||||
|
|
||||||
DRY_RUN=false
|
DRY_RUN=false
|
||||||
DESTROY_SOURCE_SNAPSHOTS=false
|
DESTROY_SOURCE_SNAPSHOTS=false
|
||||||
|
NO_UI=false
|
||||||
SSH_OPTIONS=(-o BatchMode=yes)
|
SSH_OPTIONS=(-o BatchMode=yes)
|
||||||
|
|
||||||
while (($#)); do
|
while (($#)); do
|
||||||
@@ -55,6 +57,9 @@ while (($#)); do
|
|||||||
--destroy-source-snapshots)
|
--destroy-source-snapshots)
|
||||||
DESTROY_SOURCE_SNAPSHOTS=true
|
DESTROY_SOURCE_SNAPSHOTS=true
|
||||||
;;
|
;;
|
||||||
|
--no-ui)
|
||||||
|
NO_UI=true
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
@@ -136,7 +141,7 @@ mapfile -t FILESYSTEMS < <(zfs list -H -o name -t filesystem -r "$SOURCE_POOL")
|
|||||||
|
|
||||||
# Progress UI needs a terminal and a real transfer.
|
# Progress UI needs a terminal and a real transfer.
|
||||||
UI=false
|
UI=false
|
||||||
if ! $DRY_RUN && [[ -t 1 ]]; then
|
if ! $DRY_RUN && ! $NO_UI && [[ -t 1 ]]; then
|
||||||
UI=true
|
UI=true
|
||||||
exec 4>&1
|
exec 4>&1
|
||||||
fi
|
fi
|
||||||
@@ -217,11 +222,21 @@ for filesystem in "${FILESYSTEMS[@]}"; do
|
|||||||
fi
|
fi
|
||||||
if $UI; then
|
if $UI; then
|
||||||
index_now=$((index_now + 1))
|
index_now=$((index_now + 1))
|
||||||
|
ssh_err="$(mktemp)"
|
||||||
|
send_status=0
|
||||||
{
|
{
|
||||||
zfs send -p -P -v "$snapshot" 2>&1 1>&3 3>&- \
|
zfs send -p -P -v "$snapshot" 2>&1 1>&3 3>&- \
|
||||||
| send_progress "$index_now" "${#FILESYSTEMS[@]}" "$filesystem" \
|
| send_progress "$index_now" "${#FILESYSTEMS[@]}" "$filesystem" \
|
||||||
"$prior_weight" "${WEIGHT[$filesystem]:-0}" "$TOTAL_WEIGHT"
|
"$prior_weight" "${WEIGHT[$filesystem]:-0}" "$TOTAL_WEIGHT"
|
||||||
} 3>&1 | ssh "${SSH_OPTIONS[@]}" "$REMOTE_HOST" "sudo -n zfs receive -uF '$destination'"
|
} 3>&1 | ssh "${SSH_OPTIONS[@]}" "$REMOTE_HOST" "sudo -n zfs receive -uF '$destination'" 2>"$ssh_err" \
|
||||||
|
|| send_status=$?
|
||||||
|
if ((send_status != 0)); then
|
||||||
|
printf '\nTransfer of %s failed (exit %d):\n' "$filesystem" "$send_status" >&2
|
||||||
|
cat "$ssh_err" >&2
|
||||||
|
rm -f "$ssh_err"
|
||||||
|
die "send/receive failed for $filesystem; re-run with --no-ui for plain output"
|
||||||
|
fi
|
||||||
|
rm -f "$ssh_err"
|
||||||
prior_weight=$((prior_weight + ${WEIGHT[$filesystem]:-0}))
|
prior_weight=$((prior_weight + ${WEIGHT[$filesystem]:-0}))
|
||||||
else
|
else
|
||||||
zfs send -p "$snapshot" | ssh "${SSH_OPTIONS[@]}" "$REMOTE_HOST" "sudo -n zfs receive -uF '$destination'"
|
zfs send -p "$snapshot" | ssh "${SSH_OPTIONS[@]}" "$REMOTE_HOST" "sudo -n zfs receive -uF '$destination'"
|
||||||
|
|||||||
Reference in New Issue
Block a user