Rsync - Limit the upload

Apr 30, 2012·
Julio Batista Silva
Julio Batista Silva
· 2 min read
blog Linux

Today my father asked me to send him a few things. It was 10 files of roughly 250MB each: too much work to send by email, 2.5GB would blow past my Dropbox limit, and there is still no Google Drive for Linux (only through the web, meh). The simplest solution was to store them on my own server.

My first attempt was to send them with scp:

scp -r arquivos/ julio@juliobs.com:~/www

But the transfer was running at full speed, which made the internet very slow. I could limit the speed using iptables, Trickle, pv, or even straight from the router, but none of those options are very practical.

To my delight, while reading the scp manual I noticed that its developers had already implemented an option to limit the bandwidth:

-l ;limit: Limits the used bandwidth, specified in Kbit/s.

So all I had to do was use the following command to copy the files at a speed capped at 45 Kbyte/s (360 Kbit/s):

scp -l 360 -r arquivos/ julio@juliobs.com:~/www

But before I even got around to trying that option, I remembered rsync, which has the advantage of letting you interrupt the upload and resume it later, and of syncing the files if I change something afterwards.
On top of that it also has an option to limit the upload speed:

rsync -hrPvpt --bwlimit=45 -e ssh arquivos/ julio@juliobs.com:~/www/arquivos

Do not forget to throttle your torrents too 😉.

Julio Batista Silva
Authors
Senior Cloud Developer

I’m a Brazilian computer engineer based in Germany, passionate about tech, science, photography, and languages.

I’ve been programming for about two decades already, exploring everything from mobile apps and web development to machine learning. These days I focus on cloud SRE and data engineering.

I volunteer in the open source and Python communities, helping organize PyCon DE and PyData Berlin, mentoring, and contributing with code and translations.

On my blog, I share Linux tips, setup guides, and personal notes I’ve written for future reference. I hope others find them helpful as well. The content is available in multiple languages.

Browse my gallery for some of my photography.

Away from the keyboard, you’ll find me at concerts, playing clarinet, cycling, scuba diving, or exploring new places, cultures, and cuisines.

Always happy to connect! 🙂

comments powered by Disqus