Howto limit rsync from using all the available bandwidth

undefined

In this mini post I’ll show you how to limit, and control rsync from using all the available bandwidth “limiting it’s download or upload speed” when using this important command. There are many usages for rsync, i.e copying files between servers “source, synchronizing files between two servers, and destination”, and using it as a backup tool for your files.

Here’s the issue I faced, I needed to sync files between a production “heavy loaded” server, and it’s backup server. I don’t need rsync to clog up the network connection between the production server and it’s backup server. I need to limit it’s speed to a certain value, and leave the rest of NIC bandwidth to serve the clients requests.

Naturally, limiting the amount of bandwidth your backups are using is going to make them happen more slowly, but on the other hand, your clients will not notice any slow in your server response.

The normal usage of rsync command has many forms, but for our case it looks like this:

rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST

All we need is to use —bwlimit=KBPS option “which limit I/O bandwidth; KBytes per second” with the rsync command, like this:

rsync --bwlimit=<kB/second> -av <source> <dest>

So if you wanted to limit transfer to around 10MB per second, you could use a command like this:

rsync --bwlimit=10240 -av /backup/folder user@host:/remote/backup/folder/

You’ll want to make sure to calculate the size of your backups, and figure out how long it’ll take to transfer them at a slower rate – it wouldn’t be very helpful if your backup script takes 12 hours to run, for example.

You can also use the ionice command to limit the amount of bandwidth your script uses, which will help keep your scripts from using too much disk I/O. It’s not quite as useful since you can’t set absolute numbers like you can with the —bwlimit parameter, but it’s another thing you can consider.

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

Your email address will not be published. Required fields are marked *