Added bandwidth limiter.

This commit is contained in:
Otho 2023-01-09 01:35:38 -05:00
parent 706aab7d4f
commit 4da22952cb
Signed by: Otho
GPG Key ID: 16C720CD3BBE21D9

View File

@ -21,6 +21,7 @@ ZFS_SEND_OPTS="-vpRLe"
ZFS_SNAPSHOT_OPTS="-r" ZFS_SNAPSHOT_OPTS="-r"
ZFS_RECV_OPTS="-svu" ZFS_RECV_OPTS="-svu"
SSH_SEND_OPTS="-Ti ~/.ssh/id_rsa" SSH_SEND_OPTS="-Ti ~/.ssh/id_rsa"
BANDWIDTH_LIMIT="100M"
read LOCAL_HOST LOCAL_USER LOCAL_PORT LOCAL_TZ SEND_COMPRESSED < $nodes_file read LOCAL_HOST LOCAL_USER LOCAL_PORT LOCAL_TZ SEND_COMPRESSED < $nodes_file
case $SEND_COMPRESSED in case $SEND_COMPRESSED in
@ -163,10 +164,12 @@ send_latest()
origin_snapshot=`get_latest_snapshot $dataset` origin_snapshot=`get_latest_snapshot $dataset`
if [ $BG_TEST_MODE = "TRUE" ]; then if [ $BG_TEST_MODE = "TRUE" ]; then
echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \ echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \
pv -qL $BANDWIDTH_LIMIT \| \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$dataset zfs recv $ZFS_RECV_OPTS $zroot$dataset
else else
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot | zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
pv -qL $BANDWIDTH_LIMIT |
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$dataset zfs recv $ZFS_RECV_OPTS $zroot$dataset
@ -192,12 +195,14 @@ send_increment()
echo zfs send $ZFS_SEND_OPTS \ echo zfs send $ZFS_SEND_OPTS \
-i $dataset@$remote_snapshot \ -i $dataset@$remote_snapshot \
$dataset@$origin_snapshot \| \ $dataset@$origin_snapshot \| \
pv -qL $BANDWIDTH_LIMIT \| \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$dataset zfs recv $ZFS_RECV_OPTS $zroot$dataset
else else
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 $BANDWIDTH_LIMIT |
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$dataset zfs recv $ZFS_RECV_OPTS $zroot$dataset
fi fi