Package: mirrors
Severity: wishlist
Tags: patch

When mirroring from a fast mirror over a slow link
anonftpsync can hog all the bandwith, to the detriment
of more important tasks.

Attached is a patch which uses the rsync --bwlimit
option to address this problem.

This patch is ment to be applied after the lockfile
timeout patch of Bug#441459.

Note that this patch contains tabs, because the
original anonftpsync did.

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
--- anonftpsync 2007-09-09 17:56:08.000000000 -0500
+++ anonftpsync2        2007-09-09 18:28:21.000000000 -0500
@@ -82,6 +82,12 @@
 
 MAILTO=
 
+# BWLIMIT Bandwidth limit in KBps.  Defaults to '' (unlimited).
+# Limit the maximum transfer rate to the given number of kilobits per
+# second via the rsync --bwlimit parameter.
+
+BWLIMIT=
+
 # LOCK_TIMEOUT Timeout in minutes.  Defaults to 360 (6 hours).
 # This program creates a lock to ensure that only one copy
 # of this program is mirroring any one archive at any one time.
@@ -185,11 +191,18 @@
 # specification. If that's the case on your system, try using "0".
 trap "rm -f $LOCK" exit
 
+if [ -n "$BWLIMIT" ] ; then
+  RSYNC_BWLIMIT="--bwlimit=$BWLIMIT"
+else
+  RSYNC_BWLIMIT=
+fi
+
 set +e
 
 # First sync /pool
 rsync --recursive --links --hard-links --times --verbose \
      $TMP_EXCLUDE $EXCLUDE $SOURCE_EXCLUDE \
+     $RSYNC_BWLIMIT \
      $RSYNC_HOST::$RSYNC_DIR/pool/ $TO/pool/ >> $LOGFILE 2>&1
 result=$?
 
@@ -199,6 +212,7 @@
             --exclude "Archive-Update-in-Progress-${HOSTNAME}" \
             --exclude "project/trace/${HOSTNAME}" \
             $TMP_EXCLUDE $EXCLUDE $SOURCE_EXCLUDE \
+            $RSYNC_BWLIMIT \
             $RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1
 
        LANG=C date -u > "${TO}/project/trace/${HOSTNAME}"

Reply via email to