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