Implemented new run approach.

This commit is contained in:
Otho 2023-01-16 22:18:27 -05:00
parent 5ede78973a
commit d41208cdfe
Signed by: Otho
GPG Key ID: 16C720CD3BBE21D9

View File

@ -39,6 +39,15 @@ debug()
fi fi
} }
run_send_recv()
{
if [ $ZB_TEST_MODE = "TRUE" ]; then
echo "$send_cmd | $pv_cmd | $recv_cmd"
else
$send_cmd | $pv_cmd | $recv_cmd
fi
}
set_compression() { set_compression() {
case $SEND_COMPRESSED in case $SEND_COMPRESSED in
[tTyY]*) ZFS_SEND_OPTS="$ZFS_SEND_OPTS -c" [tTyY]*) ZFS_SEND_OPTS="$ZFS_SEND_OPTS -c"
@ -151,17 +160,16 @@ zfs_allow_mirrors()
*) zroot="$zroot/" ;; *) zroot="$zroot/" ;;
esac esac
fi fi
run_cmd=" remote_cmd="
for dataset in $SEND_DATASETS; do for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2` dataset=`echo \\$dataset|cut -d: -f2`
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done done
" "
if [ $ZB_TEST_MODE = "TRUE" ]; then if [ $ZB_TEST_MODE = "TRUE" ]; then
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $remote_cmd
else else
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $remote_cmd
fi fi
done < sendnodes.tmp done < sendnodes.tmp
} }
@ -193,18 +201,13 @@ send_latest()
dataset=`echo $dataset|cut -d: -f1` dataset=`echo $dataset|cut -d: -f1`
debug "Processing $dataset (remote $remote_dataset)." debug "Processing $dataset (remote $remote_dataset)."
origin_snapshot=`get_latest_snapshot $dataset` origin_snapshot=`get_latest_snapshot $dataset`
run_cmd=" send_cmd="zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot"
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot | pv_cmd="pv -qL ${speed:-$DEF_SPEED}"
pv -qL ${speed:-$DEF_SPEED} | recv_cmd="
ssh $SSH_SEND_OPTS -o port=$ssh_port \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
$user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
" "
if [ $ZB_TEST_MODE = "TRUE" ]; then run_send_recv
echo $run_cmd
else
$run_cmd
fi
done done
done < sendnodes.tmp done < sendnodes.tmp
} }
@ -224,19 +227,16 @@ send_increment()
dataset=`echo $dataset|cut -d: -f1` dataset=`echo $dataset|cut -d: -f1`
origin_snapshot=`get_latest_snapshot` origin_snapshot=`get_latest_snapshot`
remote_snapshot=`get_latest_remote_snapshot` remote_snapshot=`get_latest_remote_snapshot`
run_cmd=" send_cmd="
zfs send $ZFS_SEND_OPTS \ zfs send $ZFS_SEND_OPTS -i $dataset@$remote_snapshot \
-i $dataset@$remote_snapshot \ $dataset@$origin_snapshot
$dataset@$origin_snapshot |
pv -qL ${speed:-$DEF_SPEED} |
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
" "
if [ $ZB_TEST_MODE = "TRUE" ]; then pv_cmd="pv -qL ${speed:-$DEF_SPEED}"
echo $run_cmd recv_cmd="
else ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
$run_cmd zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
fi "
run_send_recv
done done
done < sendnodes.tmp done < sendnodes.tmp
} }