I have server that runs a backup process (a bash script, actually) every hour. Part of this backup routine is to sync changes to a remote system (includes revision control, etc etc). This works great, takes almost no CPU or memory and is the perfect backup solution for this system.
However, the problem is that it exists on a very limited outbound bandwidth, and every hour the script locks up the system for 30-90 seconds (depending on how much needs to be synced up). It gets so bad that even when I'm using an SSH connection during the backup timeframe the terminal connection will lock up and take 5+ seconds to respond for every keystroke.
The Question: How can I limit the outbound bandwidth on a per-process, per-program, or per-script basis? If it makes a difference, I use Ubuntu server. Are there any utilities out that do this?
For extra credit, are there any C/C++ references on binding/owning network connections that I can use to create my own program? For example: Apache grabs port 80, but whenever it tries to send something out, my program would jump in and throttle the connection, in-between apache and the hardware-level network interface. Is this even possible?
(Note: I am willing to consider options that modify the linux kernel, but only if there is nothing else available).