How to Resume Interrupted File Transfers with Rsync

rsync allows you to resume an interrupted file transfer over SSH without starting from scratch – making it the perfect alternative to the scp command when handling large data files.

Quick Answer

If a file transfer using scp is interrupted, you can seamlessly resume it using rsync by running:

rsync -avP --rsh=ssh file.zip user@remote:/path/

The -P flag (which combines --progress and --partial) instructs rsync to keep the partially transferred file and resume the transfer exactly from the point of interruption.

Losing your network connection while transferring a massive multi-gigabyte backup to a Linux VPS is a nightmare if you're using standard scp (which forces you to restart from 0%). This article demonstrates how to replace it with the professional-grade rsync utility to permanently solve this issue, saving you hours of wasted bandwidth and time.

1. Quick Rsync Commands (Cheat Sheet)

Here are the definitive rsync syntaxes for resuming files in various scenarios (Upload/Download):

Task Command Execution
Resume Upload (To Remote VPS) rsync -avP file.zip user@server_ip:/path/
Resume Download (To Local PC) rsync -avP user@server_ip:/path/file.zip .
Append File (--append-verify) rsync -av --append-verify file.zip user@server_ip:/path/
Custom SSH Port rsync -avP -e 'ssh -p 2222' file.zip user@server_ip:/path/

2. Practical Example: Resuming a Broken Transfer

Imagine you were copying large-backup.tar.gz to a remote server using scp large-backup.tar.gz username@remote_server:/home/backups/ and your VPN dropped at 40%.

Do not run the SCP command again! Open your terminal and execute this instead:

RSYNC RESUME UPLOAD
rsync -avP --rsh=ssh large-backup.tar.gz username@remote_server:/home/backups/

The rsync delta-transfer algorithm will scan the existing 40% chunk on the destination, recognize the matched data, and begin transmitting exclusively from the 41% mark.

3. Why Rsync is Superior to SCP for Large Files?

  • SCP (Secure Copy): Excellent for small, quick transfers. Its fatal flaw is the lack of "Resume" capability. If a 100GB transfer fails at 99GB, SCP will silently overwrite the destination and start over from 0GB.
  • Rsync (Remote Sync): Utilizes a "Delta-transfer" algorithm. It chunks files into blocks to compare source/destination hash signatures. Thus, Rsync can intelligently "patch" and resume exactly the missing blocks.

4. Breaking Down Rsync Parameters (--partial, --append)

To truly master synchronization, you must understand the flags governing rsync's behavior:

  • -a (archive): Enables archive mode (equivalent to -rlptgoD). Preserves root structures, permissions, ownerships, and origin timestamps.
  • -v (verbose): Prints detailed output to track which files are currently syncing.
  • -P (Progress & Partial): This is the holy grail for resuming transfers.
    • --progress: Displays a live progress bar, transfer speed, and ETA.
    • --partial: Instructs rsync to keep the broken file segment instead of deleting it. This provides the baseline for the next resume attempt.
  • --append-verify (Advanced): The turbo-resume mode. Instead of hashing the entire first 40%, it assumes the beginning is identical, appends new data directly to the tail, and verifies the full checksum only at the end.

5. Bonus Tip: Create a Shell Alias for Quick Use

To avoid memorizing the full rsync -avP syntax, set up an alias in your shell configuration profile (~/.bashrc or ~/.zshrc).

Setting up the Alias:

CREATE ALIAS
echo "alias scpresume='rsync -avP --rsh=ssh'" >> ~/.bashrc

Reload configuration:

APPLY CONFIG
source ~/.bashrc

From now on, simply type scpresume file.zip user@server:/path/ instead of raw scp.

6. Conclusion

For System Administrators, deploying rsync -avP is a mandatory survival skill when operating on unstable wireless networks or international routing paths. Make it a habit to use rsync over scp whenever moving payloads larger than a few hundred Megabytes.

Is data synchronization choking your network and CPU?

Transferring massive backup payloads between servers consumes heavy Disk I/O cycles and bandwidth. Utilizing an infrastructure with wide network ports and Enterprise NVMe/SSD storage drastically reduces disconnection risks and cuts rsync synchronization time in half.

More Technical Guides

Explore additional technical guides and practical tutorials to optimize performance and manage your server infrastructure efficiently.