Using rsync to resume SCP file transfer

Using scp to transfer a large file or folder can be sometimes unstable, it doesn’t have the feature to resume broken transfers. Therefore, we have to start over each time when we cancel the transfer. There is a software called rsync that has the resume feature and it supports multiple protocols such as rsync:// and ssh://

Although it is good for both upload and download, I primarily use rsync for downloads, it will download the file list from source server and compare to whatever the files we have in our destination server (in our case, the local machine) so we don’t need to worry about file integrity and transfer resumption.

This command will do the job on our local machine:

rsync -avz -P -e "ssh" [email protected]:/path/to/folder/ ~/localpath

to download from server to ~/localpath.

If your server’s SSH port changed, you can use -e "ssh -p 12345" to indicate the port number.

Now even if you did have a network issue caused transfer interruption, you could resume the transfer by repeating the same command above once connection was re-established.

Note that rsync will not resume on a single file like HTTP 206 code does.

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.