How to Use Rsync with Progress and Bandwidth Limiting in Linux

Moving multi-gigabyte database dumps, mirror backups, or nested media archives across local disks or remote servers using standard tools like cp or scp presents severe operational drawbacks: neither command displays transfer progress, interrupted transfers force you to restart from zero, and copying over the network easily saturates bandwidth, causing network lag for other services. In Linux administration, rsync (Remote Sync) is the undisputed gold standard for file synchronization, offering differential delta-transfer algorithms, real-time transfer progress bars, and strict bandwidth throttling.

Why Rsync is Essential for Linux Administration

Rsync is far more than a simple file copier:

  • Delta-Transfer Algorithm: If a 10 GB file has only modified 50 MB of data, rsync transfers only the changed blocks over the network rather than re-sending the whole file.
  • Permission and Timestamp Preservation: The archive flag (-a) perfectly maintains owner user, group ownership, symbolic links, modification times, and permissions.
  • Partial Resume Capability: If an SSH connection drops during a massive file transfer, rsync resumes precisely where it left off using the --partial flag.

Step 1: Basic Local and Remote Rsync Syntax

The foundational command structure for rsync follows source and destination logic:

rsync [options] /path/to/source /path/to/destination

The Critical Trailing Slash Rule

Understanding trailing slashes in source directory paths is vital to prevent accidental folder nesting:

  • rsync -a /var/www/html /backup/: Copies the entire html directory itself into /backup/, producing /backup/html/.
  • rsync -a /var/www/html/ /backup/: Copies only the contents of html/ directly into /backup/ without creating an extra parent folder.

Step 2: Monitoring Transfers with Real-Time Progress

When migrating large archives, use the -P flag (combining --progress and --partial):

rsync -avhP /data/backups/ user@remote_server:/storage/backups/

Here is what each flag executes:

  • -a (archive): Recursively copies files while preserving permissions, symlinks, and timestamps.
  • -v (verbose): Displays transferring file names in the terminal.
  • -h (human-readable): Formats byte totals in KB, MB, and GB.
  • -P: Displays a real-time progress bar, transfer speed (MB/s), and estimated time of arrival (ETA), while preserving partial chunks if interrupted.

Step 3: Bandwidth Limiting with –bwlimit

On production servers or office networks with shared internet pipes, running an unrestricted rsync job can consume 100% of available upload bandwidth, choking VoIP calls and web services. Throttle transfer speeds using the --bwlimit parameter:

rsync -avhP --bwlimit=5000 /var/backups/ user@remote_server:/remote/backups/

The --bwlimit value specifies transfer ceilings in Kilobytes per second (KB/s):

  • --bwlimit=1000: Limits transfer rate to approximately 1 MB/s (~8 Mbps).
  • --bwlimit=5000: Limits transfer rate to approximately 5 MB/s (~40 Mbps).
  • --bwlimit=20M: Limits transfer rate to 20 Megabytes per second (supported in modern rsync versions).

Step 4: Performing Dry Runs to Prevent Data Loss

When utilizing the dangerous --delete flag (which purges files from the destination that no longer exist in the source), always execute a dry run first using -n:

rsync -avhnP --delete /source/ /destination/

The -n (dry run) flag simulates the entire sync process without writing, deleting, or altering a single byte on disk, allowing you to review proposed actions safely.

Essential Rsync Flag Reference

Flag Full Option Operational Role
-a --archive Preserves permissions, symlinks, owners, and timestamps
-P --partial --progress Shows real-time progress bar and resumes interrupted files
--bwlimit --bwlimit=KBPS Throttles I/O and network bandwidth to specified rate
-z --compress Compresses file data during transit across the network
-e --rsh Specifies remote shell (e.g. -e "ssh -p 2222" for custom ports)
-n --dry-run Simulates transfer without modifying filesystem

Troubleshooting Common Rsync Failures

If your rsync job terminates unexpectedly, verify these frequent failure points:

  • Connection Reset by Peer: Large transfers over unstable networks can drop. Add -e "ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=5" to keep the underlying SSH tunnel alive.
  • Permission Denied on Destination: Ensure the user account on the target machine has write permissions to the destination folder.

Leveraging rsync with progress monitoring and bandwidth throttling provides complete administrative control over Linux data migrations, ensuring fast, dependable, and non-disruptive synchronization.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.