The Danger of Unrestricted Syncs
The rsync command is the gold standard for transferring and synchronizing files between Linux servers. Because it uses delta-encoding to only transfer the changed portions of files, it is incredibly efficient. However, by default, rsync will attempt to complete the transfer as fast as the hardware allows. It will aggressively consume 100% of the available network bandwidth.
If you run a massive 500GB backup script across your corporate WAN link during business hours without throttling it, rsync will saturate the entire connection. VoLTE calls will drop, web pages will timeout, and users will complain about severe network latency. To prevent this, you must explicitly cap the bandwidth usage.
Using the Bandwidth Limit Flag
rsync includes a built-in parameter designed specifically to throttle network consumption: --bwlimit.
The syntax is incredibly simple. When executing your standard rsync command, you append the flag followed by the maximum allowable speed.
rsync -avz --bwlimit=5000 /var/www/html/ [email protected]:/backup/web/
Understanding the Measurement Metric (Crucial)
The most common mistake system administrators make is misunderstanding the metric rsync uses for the --bwlimit flag. The number you provide is measured in KiloBYTES per second (KB/s), not KiloBITS (Kbps) or MegaBYTES (MB/s).
If you have a 100 Megabit per second (100 Mbps) network connection, that translates to roughly 12.5 Megabytes per second (MB/s). If you want to limit your backup job so that it only consumes half of your connection (about 6 MB/s), you must convert 6 Megabytes into Kilobytes (6 * 1024 = 6144).
Therefore, the command to limit the transfer to 6 MB/s is:
rsync -avz --bwlimit=6144 /local/dir/ remote:/destination/
Using Modern Suffixes (rsync 3.1.0+)
If you are running a modern Linux distribution (like Ubuntu 20.04 or Debian 11), your version of rsync is likely 3.1.0 or newer. In these modern versions, the developers added support for human-readable suffixes, meaning you no longer have to do complex math to calculate Kilobytes.
You can simply append M for Megabytes. To throttle the exact same transfer to 6 Megabytes per second, you can use:
rsync -avz --bwlimit=6M /local/dir/ remote:/destination/
By enforcing this simple limit in your automated bash scripts and cron jobs, you ensure your massive file synchronizations run smoothly in the background without causing devastating network congestion for the rest of your infrastructure.