Skip to content

Rsync In ESXI

Published: 2023-02-24

Having Rsync on ESXI can be useful for many rasons. Personally, I like to use it in an SSH session to copy what I call "base" images of VMs whenever I need a new one.

Generally, I'll build a virtual machine with basic settings and create a template or base image. When I have the machine the way I like it, I'll copy it off to a storage folder on the datastore, usually called "baseimages". Whenver I need a new vm based on that "template", I'll simply copy it back and register it on the host.

Rsync is nice in this scenario because it will give a progress bar and one can also see data write speeds as well. While the web interface could be used to browse the datastore and visually start the copy from there, I prefer to use the command line - I find it a bit more robust. The web gui has a bug in it (at least on 7.0 U3) where it errors out on copy even though it still completes the task.

In order to maintain persistance on my server (USB install of ESXI) I added a couple of lines of code to the local.sh file to recreate the sym links on boot.

Installing Rsync

Main credit goes here: https://github.com/gmasonPCS/rsync-on-esxi

# Get the executable provided my gmasonPCS on github
# Notice the -no-check flag, would not work otherwise on my server
wget --no-check-certificate -S -O rsync-on-exit https://github.com/gmasonPCS/rsync-on-esxi/releases/download/Release/rsync-on-esxi.zip

# unzip to a folder on the datastore
unzip rsync-on-exit

# create a symbolic link to the file on the datastore
ln -s /vmfs/volumes/622d4808-61d34746-1916-1866da7f1485/rsync/rsync-static /bin/rsync

# change permissions on the executable
chmod 755 /bin/rsync

# edit the startup file
vi /etc/rc.local.d/local.sh

# Insert similar lines lines in the local.sh file to create the link at boot
# ln -s /vmfs/volumes/622d4808-61d34746-1916-1866da7f1485/rsync/rsync-static /bin/rsync
# /sbin/auto-backup.sh

# Execute the autobackup script to save changes in the local.sh file
# Not sure if this is necessariy
./sbin/auto-backup.sh

Sample Command

# copy contents of vm into new_vm
rsync -ah --progress ./baseimages/vm/ ./new_vm