Running rsync on ESXi is not a new topic, there are a number of users in the community who have made this work. One well-known user, Dave Mishchenko, who runs vm-help and recently authored VMware ESXi: Planning, Implementation, and Security, provides an rsync binary that can be downloaded to run on ESXi. Not that I did not trust Dave and the source of his rsync binary, but I wanted to compile my own and understand the process Dave took to get to a compatible rsync for ESXi. In talking to Dave, I found out the binary was actually provided by a VMTN user, named glim who had noted some of the details in this VMTN thread.
The user basically created a statically linked versus a dynamically linked version of rsync which runs without relying on libraries that may or may not be present on ESXi. My initial attempts failed using both a 32/64bit CentOS 5.5 and latest version of rsync 3.0.7 and 3.0.3. The compilation of rsync was successful, but upon executing on ESXi, it immediately had a segmentation fault. I started to think there might be some dependencies in libraries that were used to compile rsync that I was missing. I was also in conversation with Alain Spineux, creator of MKSBackup regarding this same topic and he had found a way to compile rsync based on the article Hacking ESXi by Stjepan Groš.
Stejepan found that using CentOS 3.9, one could compile both statically and dynamically linked binaries without any modifications to ESXi. Though Stejepan did not provide the steps to compile rsync, it is relatively simple to do so. I also found that you do not need to use older 3.0.3 release of rsync, you can use the latest version which is 3.0.7 as of writing this article.
Before we get started, let me remind you of the disclaimer:
*** THIS IS PROBABLY NOT SUPPORTED BY VMWARE, USE AT YOUR OWN RISK ***
Download and install CentOS 3.9 i386 - You can find a list of download sites here
With a default installation of CentOS 3.9, you just need to get GCC installed
yum -y install gcc
Next you will need to download the latest version of rsync which is 3.0.7 here and SCP it to your CentOS system
Next you will now extract the contents of the rsync-3.0.7.tar.gz
tar -zxvf rsync-3.0.7.tar.gz
Now you will change into the rsync-3.0.7 directory and run the configure command
./configure
Now you will run the make command which will compile rsync, but you will also be passing in additional flags to create a statically linked binary
make CFLAGS="-static" EXEEXT="-static"
Finally, you will need to run the strip utility which discards all symbols from object files
strip rsync-static
You now have a self-contain rsync binary labeled rsync-static found in the current working directory
Next up, you will SCP the rsync-static binary to your ESX(i) host and set the appropriate permissions to execute. I decided to temporarily store it in /tmp, but if you want the binary to persist through a reboot, you may want to store it in either a local or remote VMFS/NFS volume.
I quickly verified that rsync was in functional, by rsyncing /etc directory in ESXi over to another host. I use the following command:
/tmp/rsync-static --compress --progress --stats -e dbclient -Rr /etc build-centos:/upload
Once the file transfer has completed, you should see the /etc directory replicated on the destination host.
You may have noticed in the command line we are specifying "dbclient", by default rsync will go over SSH but ESXi does not actually have the traditional ssh client that we are all used to. It actually uses dropbear which is tiny SSH server and client which is frequently used in embedded systems such as Busybox.
Since /bin/ssh path does not exists, rsync will fail unless you specify the dbclient to the -e parameter.
Alain also found that retrieving peer name may fail and the rsync code currently does not properly handle this failure and just exits. By looking at the clientname.c source code which is part of rsync, Alain noted that even the developers left a comment that states the error could probably be handled without exiting. The fix is to just comment out the rsynerr line which does not force the program to exit when hitting this problem and this can be found on line 171.
Once you have made the changes, you just need to follow the instructions above to compile your static rsync binary. This is not necessary required, but if you run into this issue, this is a quick hack that can help.
I would like to thank Alain for sharing this tidbit of information