• Posted: 16-07-2025
  • Last Updated: 10-08-2025
  • Category: Server Guides

Transferring a large file over an unstable network can often be interrupted, wasting time by forcing you to start over. Fortunately, the powerful rsync utility provides an effective solution to resume the transfer right where it left off, replacing the traditional scp command.

This article will show you exactly how to do it.

Table of Contents

1. Quick Comparison: scp vs. rsync

Both are tools for transferring files over SSH, but they have a key functional difference:

  • scp (Secure Copy): Simple, secure, and great for one-off copies of small files. However, it does not support resuming interrupted transfers.
  • rsync (Remote Sync): Much more powerful, capable of syncing (only transferring differences), compressing data, and most importantly, it can resume failed file transfers.

2. Scenario: A File Transfer with scp Fails

Let's say you are trying to copy the file large-backup.tar.gz to a remote server with the command:

scp large-backup.tar.gz username@remote_server:/home/user/backups/

Halfway through the process, your network connection is lost. Instead of running the same scp command again, we'll use rsync.

3. Solution: Using rsync to Resume the Transfer

Open your terminal again and execute the following command:

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

rsync will check the partially transferred file on the destination server and will only send the missing parts, saving you a significant amount of time.

Breaking Down the Command Parameters

Let's analyze the important flags we used:

  • -a (archive): Enables archive mode, which is equivalent to -rlptgoD. It preserves file attributes like permissions, ownership, timestamps, etc.
  • -v (verbose): Shows detailed output of the process.
  • -P: This is a very useful flag, combining --progress (shows a progress bar) and --partial (keeps partially transferred files). This is the key flag that enables the resume capability.
  • --rsh=ssh: Specifies that rsync must use the SSH protocol for the connection, ensuring the transfer is encrypted and secure, just like scp.

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

To avoid typing the long command every time, you can create a shortcut (alias) in your shell's configuration file (e.g., ~/.bashrc or ~/.zshrc).

Add the following line to the end of the file:

alias scpresume='rsync -avP --rsh=ssh'

Save the file and run source ~/.bashrc (or source ~/.zshrc). From now on, you only need to type:

scpresume large-backup.tar.gz username@remote_server:/home/user/backups/

5. Conclusion

While scp is an excellent choice for quick copies of small files, rsync is the true professional tool for large transfers or for use over unstable connections. Its ability to resume failed transfers is a real lifesaver that saves time and effort.

Share:
Rating:

( Total: 1 ratings. Average 5, scale: 1 to 5 )