Why Throttle Backups?
Backups can consume significant bandwidth and I/O, especially initial full backups. Without throttling, they can saturate your network, increase user latency, and cause disk I/O contention. Proper throttling ensures backups complete without degrading service quality.
Network Bandwidth Throttling
# Rsync with bandwidth limit
rsync -avz --bwlimit=50000 /var/www/ backup-server:/backup/www/
# Dynamic throttling based on time of day
HOUR=$(date +%H)
if [ "$HOUR" -ge 8 ] && [ "$HOUR" -lt 22 ]; then
BWLIMIT="--bwlimit=10000" # 10 MB/s business hours
else
BWLIMIT="--bwlimit=0" # Unlimited at night
fi
rsync -avz $BWLIMIT /data/ backup:/backup/data/
# Rclone time-based schedule
rclone sync /backup remote:bucket --bwlimit "08:00,10M 23:00,100M 00:00,off"
# Restic bandwidth limits
restic backup /data --limit-upload 20480 # 20 MB/s
I/O Throttling
# Lowest I/O and CPU priority
ionice -c 3 nice -n 19 /usr/local/bin/backup.sh
# Systemd service with resource limits
[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
Nice=19
IOSchedulingClass=idle
CPUWeight=10
IOWeight=10
MemoryMax=4G
Intelligent Scheduling
#!/bin/bash
# Smart backup - defer if server is busy
LOAD=$(awk '{print $1}' /proc/loadavg)
THRESHOLD=$(echo "$(nproc) * 0.7" | bc)
if (( $(echo "$LOAD > $THRESHOLD" | bc -l) )); then
echo "Load too high, deferring..."
echo "/usr/local/bin/smart-backup.sh" | at now + 30 minutes
exit 0
fi
# Check network utilization
RX1=$(cat /sys/class/net/eth0/statistics/rx_bytes)
sleep 2
RX2=$(cat /sys/class/net/eth0/statistics/rx_bytes)
BW_MBPS=$(( (RX2 - RX1) / 2 / 1024 / 1024 * 8 ))
if [ "$BW_MBPS" -gt 800 ]; then
echo "Network busy, deferring..."
echo "/usr/local/bin/smart-backup.sh" | at now + 15 minutes
exit 0
fi
ionice -c 3 nice -n 19 restic backup /data --limit-upload 10240
Monitoring Performance
START=$(date +%s)
START_BYTES=$(cat /sys/class/net/eth0/statistics/tx_bytes)
restic backup /data --limit-upload 20480
DURATION=$(($(date +%s) - START))
TRANSFERRED=$(( ($(cat /sys/class/net/eth0/statistics/tx_bytes) - START_BYTES) / 1048576 ))
echo "Backup: ${TRANSFERRED}MB in ${DURATION}s" >> /var/log/backup-perf.log
Best Practices
- Schedule full backups off-peak; incremental backups can run during day with throttling
- Use ionice class 3 (idle) so backups never compete with production I/O
- Monitor completion times for trends
- Use time-based throttling profiles that adjust automatically
- Always leave bandwidth headroom
- Verify throttled backups still complete within your backup window