How to fix corrupt packet error for with rsync for large files

In order to have local copies of my web pages hosted on VPS I have configured rsync cronjob to sync everything during the night to my local box.

Sometimes with larger files you can encounter errors like these:

Received disconnect from [YOUR_IP]: 2: Packet corrupt
rsync: [sender] write error: Broken pipe (32)
rsync error: unexplained error (code 255) at io.c(820) [sender=3.1.1]

The command I have used for syncing my public_html directory was:

rsync  --bwlimit=256 --delete -avz -e 'ssh -p 443' --exclude /home/xyz/public_html/wp-content/cache/ /home/
xyz/public_html/ user@[YOUR_IP]:/home/xyz/public_html/

Adding rsync options like –progress –partial can help you  to continue sync of your interrupted files.

rsync --progress --partial --bwlimit=256 --delete -avz -e 'ssh -p 443 -o ConnectTimeout=2 -o ServerAliveInterval=2 -ServerAliveCountMax=2' --exclude /home/xyz/public_html/wp-content/cache/ /home/
xyz/public_html/ user@[YOUR_IP]:/home/xyz/public_html/

As you can see I have added couple of ssh option flags as well.

Now in case your connection is interrupted you will see something like this:

wp-content/uploads/2017/04/[YOUR_LARGE_FILE]
 17,170,432 19% 259.44kB/s 0:04:25 Received disconnect from [YOUR_IP]: 2: Packet corrupt

rsync: [sender] write error: Broken pipe (32)
rsync error: unexplained error (code 255) at io.c(820) [sender=3.1.1]

But if you run again your sync command it will continue interrupted download:

# rsync.sh
sending incremental file list

sent 259 bytes received 12 bytes 108.40 bytes/sec
total size is 49,777,673 speedup is 183,681.45
sending incremental file list
wp-content/uploads/2017/04/
wp-content/uploads/2017/04/[YOUR_LARGE_FILE]
 21,311,088 24% 256.00kB/s 0:04:13

Although this will not prevent corrupt packet from happening it will at least save you the time and bandwidth not to re-upload from files from the beginning over and over.

2 Replies to “How to fix corrupt packet error for with rsync for large files”

Leave a Reply

Your email address will not be published. Required fields are marked *