Resume scp/rsync file transfer
This is very basic Linux knowledge, but the question has arisen too often and I decided to document it.
Problem:
Transfer (or upload/download) a large tree of files and directories from one machine to another using a ssh connection, and being able to resume/continue if the operation is interrupted.
Solution:
Until now, I believe that the best solution is using rsync over ssh, since rsync has a feature to resume interrupted file transfer, even when an entire tree of directories is involved.
Command line:
rsync -vrlPtz -e ssh host:/remote_path/* /local_path/
Explained:
-e ssh rsync will use ssh client instead of rsh
-z compress file transfer
-t preserve time (other attributes as owner or permissions are also possible)
-l copy symlinks as symlinks
-P resume incomplete file transfer
-r recursive into subdirectories
-v verbose
Optionally, you may also add following options, that make sense only if both machines have the save user name space:
-p preserve permissions
-o preserve owner
-g preserve group

