Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bandwidth limit support #661

Closed
chebee7i opened this issue Feb 14, 2016 · 5 comments
Closed

Add bandwidth limit support #661

chebee7i opened this issue Feb 14, 2016 · 5 comments

Comments

@chebee7i
Copy link

This issue appears on the checkbox list in #5. It is attic issue: jborg/attic#103. I wasn't sure if we should be adding comments there or here.


The original issue requests that support be added to limit bandwidth. trickle was mentioned as an option. People said it wouldn't/didn't work since borg uses a pipe through ssh, while trickle works with sockets.

I just wanted to report that if you are using borg with sshfs (i.e. backing up to rsync.net), then using trickle will work properly. You must call trickle when performing the ssh mount. So to limit bandwidth to 5 Mbps, you'd use:

trickle -u 5000 sshfs username@hostname: /path/to/mountpoint
borg create ...
@manwegit
Copy link

Limiting bandwidth can be accomplished with pipeviewer and a wrapper script.
My take on this is that documenting pv is preferable to adding bandwidth support to borg, because pv does what is needed and rate-limiting is not always easy to do in code (+ adds more complexity to already complex setup). With unix philosophy: do one thing and do it well (and pipes, I like pipes... ;)

Install pipeviewer (pv) on ubuntu and most likely debian it's simply: sudo apt-get install pv

Create a wrapper script: (I'll create it to /usr/local/bin/pv-wrapper)

#!/bin/bash
     ## -q, --quiet              do not output any transfer information at all
     ## -L, --rate-limit RATE    limit transfer to RATE bytes per second
export RATE=307200
pv -q -L $RATE  | "$@"

That done, add BORG_RSH env
export BORG_RSH='/usr/local/bin/pv-wrapper.sh ssh '

Now borg will be bandwidth limited. Nice thing about pv is that you can change rate-limit on the fly:
pv -R $(pidof pv) -L 102400

I've used same setup with rsync where I was moving multi terabyte set of data and had to moderate bandwidth during office hours.

# example cron setup:
00 09 * * 1-5 root ( pidof pv > /tmp/.pv-pid && pv -R $(cat /tmp/.pv-pid ) -L  307200)
00 18 * * * root ( pidof pv > /tmp/.pv-pid && pv -R $(cat /tmp/.pv-pid ) -L  819200)

Test:
Remote repo was removed before each test

source: 320M total
Without pipeviewer:
Duration: 5 minutes 8.50 seconds
Number of files: 60

## wrapper:
pv -q -L 307200 | "$@"
Duration: 18 minutes 7.00 seconds

pv -q -L 102400 | "$@"
Stopped exection after 40 mins, expected run time around 54 minutes and borg --progress output was inline with the estimate.

Original test with pipeviewer, but no rate-limit:
Duration: 6 minutes 29.38 seconds
please note that this test was not run on laboratory conditions so other users affect bandwidth availability.

@ThomasWaldmann
Copy link
Member

could be added to faq.

@ThomasWaldmann
Copy link
Member

merged pr #705.

@ddevault
Copy link

ddevault commented May 4, 2020

Bumping an old issue here, I know, but that's a rather convoluted workaround for something that probably ought to live in borg. Plus, it would be useful to have separate throttling options for network, I/O, and compute.

@ThomasWaldmann
Copy link
Member

@ddevault if you have a specific problem related to this, please describe it in a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants