How to resume scp with partially copied files? [closed]

You should use rsync over ssh

rsync -P -e ssh remoteuser@remotehost:/remote/path /local/path

The key option is -P, which is the same as --partial --progress

By default, rsync will delete any partially transferred file if the transfer is interrupted. In some circumstances it is more desirable to keep partially transferred files. Using the --partial option tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.

Other options, such -a (for archive mode), and -z (to enable compression) can also be used.

The manual: https://download.samba.org/pub/rsync/rsync.html


An alternative to rsync:

Use sftp with option -r (recursively copy entire directories) and option -a of sftp's get command "resume partial transfers of existing files."

Prerequisite: Your sftp implementation has already a get with -a option.

Example:

Copy directory /foo/bar from remote server to your local current directory. Directory bar will be created in your local current directory.

echo "get -a /foo/bar" | sftp -r user@remote_server

Since OpenSSH 6.3, you can use reget command in sftp.

It has the same syntax as the get, except that it starts a transfer from the end of an existing local file.

echo "reget /file/path" | sftp -r user@server_name

The same effect has -a switch to the get command or global command-line -a switch of sftp.


Another possibility is to try to salvage the scp you've already started when it stalls.

ctrl+z to background and stop it, then ssh over to the receiving server and login, then exit. Now fg the scp process and watch it resume from 'stalled'!