Tag: rsync

  • Rsync error when connecting to CentOS: rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]

     

    We helped rebuild a backup VM which receives data over rsync today; the first rsync attempt failed with the vague error message:

     

    rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]

     

    The problem ended up being that the rsync package was not installed. A simple:

     

    yum install rsync -y

     

    …fixed the problem and shortly the backups were back to normal.

  • Performing a dry run with rsync

     

    One of the many useful options rsync offers is the ability to do a dry-run – in effect showing you what it would do without actually making any changes. To achive this we use the -n flag, like so:

     

    rsync -n /source /destination

     

    In practice we would likely use the -n switch in combination with other switches – commonly we use -avzP, so our real-world example would look like this:

     

    rsync -avzP -n /source /destination

     

    Thanks to the verbose flag (-v) you should see a full list of all of the files which would be transferred, as well as the final note on the last two lines:

     

    sent 26457 bytes  received 2086 bytes  19028.67 bytes/sec
    total size is 26377806232  speedup is 924142.74 (DRY RUN)

     

    …letting you know that it was a dry run and that no files were transferred.

  • Using rsync with a non-standard SSH port

     

    There are many reasons you may be using an SSH port other than 22; perhaps you changed it as a security measure, or perhaps you have multiple machines behind your firewall which you are port forwarding to and thus have to use other ports in addition to 22. Rsync is an extremely powerful file synchronization tool which by default uses SSH to connect your source and destination, thus if you have changed your SSH port you will need to tell rsync. This can be easily done with the e switch like so (using 2222 as the new SSH port as an example):

     

    rsync -e “ssh -p 2222” /path/to/source [email protected]:/path/to/destination

     

    As a practical example using the other options -avzP (our typical selection) your command might look like:

     

    rsync -avzP -e “ssh -p 2222” /home/user/myfile [email protected]:/home/user/