aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS4
-rw-r--r--etc/backupninja.conf.in1
-rw-r--r--examples/example.rdiff7
-rw-r--r--handlers/rdiff21
-rwxr-xr-xsrc/backupninja.in1
5 files changed, 32 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index fd30f8e..03a9de4 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -19,5 +19,5 @@ Daniel.Bonniot@inria.fr
Brad Fritz <brad@fritzfam.com> -- trac patch
garcondumonde@riseup.net
Martin Krafft madduck@debian.org -- admingroup patch
-Anarcat
-
+Anarcat -- lotsa patches
+Jamie McClelland - cstream patches
diff --git a/etc/backupninja.conf.in b/etc/backupninja.conf.in
index 951a8ca..090561f 100644
--- a/etc/backupninja.conf.in
+++ b/etc/backupninja.conf.in
@@ -62,6 +62,7 @@ vservers = no
# SLAPCAT=/usr/sbin/slapcat
# LDAPSEARCH=/usr/bin/ldapsearch
# RDIFFBACKUP=/usr/bin/rdiff-backup
+# CSTREAM=/usr/bin/cstream
# MYSQL=/usr/bin/mysql
# MYSQLHOTCOPY=/usr/bin/mysqlhotcopy
# MYSQLDUMP=/usr/bin/mysqldump
diff --git a/examples/example.rdiff b/examples/example.rdiff
index 25cd26e..5ad700b 100644
--- a/examples/example.rdiff
+++ b/examples/example.rdiff
@@ -13,6 +13,13 @@
## default is yes. set to no to skip the test if the remote host is alive
# testconnect = no
+## default is not to limit bandwidth.
+## set to a number in bytes/second to limit bandwidth usage. Use a negative
+## number to set a limit that will never be exceeded, or a positive number
+## to set a target average bandwidth use. cstream is required. See cstream's
+## -t option for more information. 62500 bytes = 500 Kb (.5 Mb)
+# bwlimit = 62500
+
######################################################
## source section
## (where the files to be backed up are coming from)
diff --git a/handlers/rdiff b/handlers/rdiff
index bdc1cbd..5561435 100644
--- a/handlers/rdiff
+++ b/handlers/rdiff
@@ -64,11 +64,19 @@ function check_consistency() {
fi
}
+function check_cstream() {
+ local cstream=$1
+ if [ ! -x $cstream ]; then
+ fatal "Can't find your cstream binary (trying: $cstream). If you use bwlimit you must have cstream installed."
+ fi
+}
+
### GET CONFIG ###
getconf options
getconf testconnect yes
getconf nicelevel 0
+getconf bwlimit
setsection source
getconf type; sourcetype=$type
@@ -167,6 +175,19 @@ if [ $test = 0 ]; then
fi
fi
+# Add cstream
+
+if [ ! -z $bwlimit ]; then
+ check_cstream $CSTREAM;
+ if [ "$desttype" = "remote" ]; then
+ RDIFFBACKUP="$RDIFFBACKUP --remote-schema 'cstream -t $bwlimit | ssh %s \''rdiff-backup --server\'''"
+ elif [ "$sourcetype" = "remote" ]; then
+ RDIFFBACKUP="$RDIFFBACKUP --remote-schema 'ssh %s \''rdiff-backup --server\'' | cstream -t $bwlimit'"
+ else
+ fatal "You specified a bandwidth limit but neither your source nor destination types are remote."
+ fi
+fi
+
### EXECUTE ###
execstr="$RDIFFBACKUP $options --print-statistics "
diff --git a/src/backupninja.in b/src/backupninja.in
index 7430176..6295198 100755
--- a/src/backupninja.in
+++ b/src/backupninja.in
@@ -445,6 +445,7 @@ getconf usecolors "yes"
getconf SLAPCAT /usr/sbin/slapcat
getconf LDAPSEARCH /usr/bin/ldapsearch
getconf RDIFFBACKUP /usr/bin/rdiff-backup
+getconf CSTREAM=/usr/bin/cstream
getconf MYSQLADMIN /usr/bin/mysqladmin
getconf MYSQL /usr/bin/mysql
getconf MYSQLHOTCOPY /usr/bin/mysqlhotcopy