From 005ecf6cfbf1977783b7dd7b4e98af8ce28db378 Mon Sep 17 00:00:00 2001 From: "Alan J. Pippin" Date: Sat, 17 Jan 2009 15:39:51 -0700 Subject: [PATCH] Added new throttle option --- zfs-replicate | 27 +++++++++++++++++++++------ zfs-scripts.conf.dist | 5 +++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/zfs-replicate b/zfs-replicate index c7e7c2f..84c8c5b 100755 --- a/zfs-replicate +++ b/zfs-replicate @@ -177,8 +177,13 @@ if [ $no_markers == 0 ]; then fatal_and_exit "-E- remote incremental $zfs rollback command failed" $mailto fi # Now it should be safe to send the snaps - ssh $remote $zfs send -R -I${previous_backup_marker} ${current_backup_marker} | - $zfs receive -vF -d ${local_pool}/${remote_pool} + if [[ $throttle_enable == 1 && -e $throttle ]]; then + ssh $remote $zfs send -R -I${previous_backup_marker} ${current_backup_marker} | + $throttle $throttle_opts | $zfs receive -vF -d ${local_pool}/${remote_pool} + else + ssh $remote $zfs send -R -I${previous_backup_marker} ${current_backup_marker} | + $zfs receive -vF -d ${local_pool}/${remote_pool} + fi if [ $? != 0 ]; then fatal_and_exit "-E- remote incremental $zfs send command failed" $mailto fi @@ -197,8 +202,13 @@ else if [[ -n "$common" ]]; then # We found a common snapshot, incrementally send the new snaps - ssh $remote $zfs send -R -I${common/*@/@} ${current_backup_marker} | - $zfs receive -vF -d ${local_pool}/${remote_pool} + if [[ $throttle_enable == 1 && -e $throttle ]]; then + ssh $remote $zfs send -R -I${common/*@/@} ${current_backup_marker} | + $throttle $throttle_opts | $zfs receive -vF -d ${local_pool}/${remote_pool} + else + ssh $remote $zfs send -R -I${common/*@/@} ${current_backup_marker} | + $zfs receive -vF -d ${local_pool}/${remote_pool} + fi if [ $? != 0 ]; then fatal_and_exit "-E- remote incremental $zfs send command failed" $mailto fi @@ -220,8 +230,13 @@ else fi fi # Send the full filesystem - ssh $remote $zfs send -R ${current_backup_marker} | - $zfs receive -vF -d ${local_pool}/${remote_pool} + if [[ $throttle_enable == 1 && -e $throttle ]]; then + ssh $remote $zfs send -R ${current_backup_marker} | + $throttle $throttle_opts | $zfs receive -vF -d ${local_pool}/${remote_pool} + else + ssh $remote $zfs send -R ${current_backup_marker} | + $zfs receive -vF -d ${local_pool}/${remote_pool} + fi if [ $? != 0 ]; then fatal_and_exit "-E- remote full $zfs send command failed" $mailto fi diff --git a/zfs-scripts.conf.dist b/zfs-scripts.conf.dist index 42f387d..cd9a818 100644 --- a/zfs-scripts.conf.dist +++ b/zfs-scripts.conf.dist @@ -39,6 +39,11 @@ SNAP_UNDER_TEST= # Specify the maximum run time in minutes that the replicate script can run for (0=no limit) maxruntime=0 +# Setup throttling related parameters that will rate limit the zfs send | zfs receive pipe +throttle_enable=1 +throttle_opt="-M 5" +throttle=/usr/local/bin/throttle + # Specify the list of filesystems to replicate from the remote to the local_pool (1 per line) # (enter 1 filesystem per line) filesystems_to_replicate=' -- 2.34.1