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

Are you transferring a large file with scp only to have your network connection drop? It's frustrating to start over from scratch. This article will show you how to use the powerful rsync utility to resume the transfer right where it left off.

Quick Comparison: scp vs. rsync

Both are tools for transferring files over SSH, but they have a key 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.

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 to continue.

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 rsync Command

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.

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/

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 )