diff --git a/backup.sh b/backup.sh index e30ea7c..f4ad6c8 100755 --- a/backup.sh +++ b/backup.sh @@ -21,7 +21,7 @@ ZFS_SEND_OPTS="-pRLe" ZFS_SNAPSHOT_OPTS="-r" ZFS_RECV_OPTS="-vsu" SSH_SEND_OPTS="-Ti ~/.ssh/id_rsa" -BANDWIDTH_LIMIT="100M" +DEF_SPEED="20M" read LOCAL_HOST LOCAL_USER LOCAL_PORT LOCAL_TZ SEND_COMPRESSED < $nodes_file case $SEND_COMPRESSED in @@ -66,7 +66,7 @@ list_datasets() } list_remote_datasets() { - while read addr user ssh_port zroot; do + while read addr user ssh_port zroot speed; do echo "=== $user@$addr $zroot ===" if [ $zroot ]; then case $zroot in @@ -122,7 +122,7 @@ zfs_allow_origin() zfs_allow_mirrors() { - while read addr user ssh_port zroot; do + while read addr user ssh_port zroot speed; do echo "=== $user@$addr $zroot ===" if [ $zroot ]; then case $zroot in @@ -160,7 +160,7 @@ create_snapshots() send_latest() { - while read addr user ssh_port zroot; do + while read addr user ssh_port zroot speed; do echo "=== $user@$addr $zroot ===" if [ $zroot ]; then case $zroot in @@ -174,12 +174,12 @@ send_latest() origin_snapshot=`get_latest_snapshot $dataset` if [ $BG_TEST_MODE = "TRUE" ]; then echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \ - pv -qL $BANDWIDTH_LIMIT \| \ + pv -qL ${speed:-$DEF_SPEED} \| \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset else zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot | - pv -qL $BANDWIDTH_LIMIT | + pv -qL ${speed:-$DEF_SPEED} | ssh $SSH_SEND_OPTS -o port=$ssh_port \ $user@$addr \ zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset @@ -190,7 +190,7 @@ send_latest() send_increment() { - while read addr user ssh_port zroot; do + while read addr user ssh_port zroot speed; do echo "=== $user@$addr $zroot ===" if [ $zroot ]; then case $zroot in @@ -207,14 +207,14 @@ send_increment() echo zfs send $ZFS_SEND_OPTS \ -i $dataset@$remote_snapshot \ $dataset@$origin_snapshot \| \ - pv -qL $BANDWIDTH_LIMIT \| \ + pv -qL ${speed:-$DEF_SPEED} \| \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset else zfs send $ZFS_SEND_OPTS \ -i $dataset@$remote_snapshot \ $dataset@$origin_snapshot | - pv -qL $BANDWIDTH_LIMIT | + pv -qL ${speed:-$DEF_SPEED} | ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset fi