From fcdbaa3447e70a9047a12f342b66dd1cea6d61e4 Mon Sep 17 00:00:00 2001
From: Jerome Charaoui <jerome@riseup.net>
Date: Fri, 19 Jan 2018 15:02:54 -0500
Subject: [PATCH] [borg] add bwlimit config (sets --remote-ratelimit)

---
 examples/example.borg | 6 ++++++
 handlers/borg.in      | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/examples/example.borg b/examples/example.borg
index 51ff90e..1ea48ab 100644
--- a/examples/example.borg
+++ b/examples/example.borg
@@ -23,6 +23,12 @@
 ## Default:
 # testconnect = yes
 
+## default is not to limit bandwidth. 
+## set to a number in kiBytes/second to limit bandwidth usage. 
+##
+## Default:
+# bwlimit = 0
+
 ######################################################
 ## source section
 ## (where the files to be backed up are coming from)
diff --git a/handlers/borg.in b/handlers/borg.in
index 54574c4..3a8c048 100644
--- a/handlers/borg.in
+++ b/handlers/borg.in
@@ -20,6 +20,7 @@ export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
 
 getconf testconnect yes
 getconf nicelevel 0
+getconf bwlimit
 
 setsection source
 getconf prune yes
@@ -118,6 +119,10 @@ IFS=$SAVEIFS
 
 set +o noglob
 
+if [ ! -z $bwlimit ]; then
+   execstr="${execstr} --remote-ratelimit=${bwlimit}"
+fi
+
 # include client-part and server-part
 execstr="${execstr} ${excludes} $execstr_repository::$execstr_archive ${includes}"
 debug "$execstr"
-- 
GitLab