How to fix corrupt packet error for with rsync for (relatively) large files?
I'm not sure what might cause the corrupt packet
problem that drops your connection, but you might find rsync's --partial
or --partial-dir
option helpful when transferring large files so that when you restart the transfer it will continue where the transfer left off instead of having to start over transferring the whole file again:
--partial-dir=.rsync-partial
So you can modify your original command like this:
rsync -rav --progress --partial -e "ssh -o ConnectTimeout=2 -o ServerAliveInterval=2 -ServerAliveCountMax=2" --delete ./local_dir user@$SERVER:/dest_dir
or
rsync -rav --progress --partial-dir=.rsync-partial -e "ssh -o ConnectTimeout=2 -o ServerAliveInterval=2 -ServerAliveCountMax=2" --delete ./local_dir user@$SERVER:/dest_dir
Note that for this example I removed the -q
(--quiet
) option and added the --progress
option in the first example and --partial-dir=.rsync-partial
in the second example.
The difference between --partial
and --partial-dir=.rsync-partial
is that the later creates a directory that keeps the partial files separate from the fully-transferred files if that is important to you on the receiving (server) side.
The rsync manpage will explain this in further detail, though I'll also point out an important security note from the manpage:
IMPORTANT: the --partial-dir should not be writable by other users or it is a security risk. E.g. AVOID "/tmp".
The corruption suggests a bad NIC or NIC driver in your machine; had this once on my wife's Windows box: had to repeatedly try to get rsync installed. Once that succeeded, I could repeatedly invoke rsync to transfer and fix the other software needed, which most notably included updated NIC drivers and a checksum tool.