├── Dockerfile ├── README.md ├── rsync ├── rsync-esxi-compiler-docker.sh └── rsync-esxi-compiler.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7 2 | 3 | ARG RSYNC_VERSION=v3.4.1 4 | 5 | # fix yum repo URLs for CentOS 7 EOL 6 | RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/CentOS-*.repo && \ 7 | sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/CentOS-*.repo && \ 8 | sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/CentOS-*.repo 9 | 10 | RUN yum -y install \ 11 | epel-release \ 12 | git \ 13 | lz4-devel \ 14 | lz4-static \ 15 | openssl-static \ 16 | python3-pip \ 17 | python3-devel \ 18 | glibc-static \ 19 | popt-devel \ 20 | popt-static \ 21 | make \ 22 | automake \ 23 | gcc \ 24 | wget \ 25 | doxygen \ 26 | rpm-build 27 | 28 | RUN yum -y install \ 29 | libzstd-devel \ 30 | libzstd \ 31 | libzstd-static \ 32 | xxhash-devel \ 33 | && \ 34 | python3 -mpip install --user commonmark 35 | 36 | RUN cd / && \ 37 | wget https://archives.fedoraproject.org/pub/archive/epel/7/SRPMS/Packages/x/xxhash-0.8.2-1.el7.src.rpm && \ 38 | rpm -ivh xxhash-*.el7.src.rpm && \ 39 | cd ~/rpmbuild/SPECS && \ 40 | rpmbuild -bp xxhash.spec && \ 41 | cd ~/rpmbuild/BUILD/xxHash-*/ && \ 42 | make install 43 | 44 | RUN cd / && \ 45 | git clone https://github.com/RsyncProject/rsync.git && \ 46 | cd rsync && \ 47 | git checkout $RSYNC_VERSION 48 | 49 | WORKDIR /rsync 50 | 51 | RUN cd /rsync && \ 52 | LIBS="-ldl" ./configure && \ 53 | make -B CFLAGS="-static -std=c99" 54 | 55 | RUN echo If build was successful, below output should state: 'not a dynamic executable' && \ 56 | ldd rsync || \ 57 | true 58 | 59 | RUN ./rsync -V 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RSYNC for ESXi 2 | ### Build scripts for compiling rsync for use with VMware ESXi 3 | Rsync is a mature Linux staple for reliably replicating files over imperfect or lower speed links. For data migration it is particularly useful for keeping track of data changes between systems during a staged migration, but it is equally useful as a backup or disaster recovery tool. 4 | 5 | If you dont want to build your own (and you trust this repo), a prebuilt rsync executable is available here: [rsync v3.4.1 for ESXi](https://github.com/itiligent/RSYNC-for-ESXi/raw/main/rsync) 6 | 7 | ## Compile rsync with Centos 7 or Docker 8 | You will need either: 9 | - For source build, an instance of Centos 7 OS _[Get the Centos 7 ISO here]( https://buildlogs.centos.org/centos/7/isos/x86_64/)_ 10 | - For Docker build, Docker pre installed (any host OS). 11 | 12 | **To compile rsync natively within Centos 7:** 13 | ``` 14 | 1a. chmod +x rsync-esxi-compiler.sh && ./rsync-esxi-compiler.sh 15 | ``` 16 | **To compile rsync within a Docker container:** 17 | ``` 18 | 1b. chmod +x rsync-esxi-compiler-docker.sh && ./rsync-esxi-compiler-docker.sh 19 | ``` 20 | **Common completion steps:** 21 | ``` 22 | 2. Copy the completed rsync binary to a *persistent* location in ESXi: e.g. any VMFS datastore or /productLocker/ are good locations 23 | 3. In ESXi set execute permissions on rsync: chmod 755 rsync 24 | 4. ESXi 8 only (By default ESXi 8 blocks execution of non-native binaries). 25 | To temporarily override this restriction...: esxcli system settings advanced set -o /User/execInstalledOnly -i 0 26 | To restore the default.....................: esxcli system settings advanced set -o /User/execInstalledOnly -i 1 27 | To check status............................: esxcli system settings advanced list -o /User/execInstalledOnly 28 | ``` 29 | 30 | ## ESXi rsync examples: 31 | 32 | ALERT: ESXI 8 blocks the execution of non native binaries by default. 33 | - To run rsync you must disable this restriction with: `esxcli system settings advanced set -o /User/execInstalledOnly -i 0` 34 | - Re-enable the restriction: `esxcli system settings advanced set -o /User/execInstalledOnly -i 1` 35 | 36 | ### rsync via SSH (prompts for destination's password): 37 | ``` 38 | /productLocker/rsync -avurP --delete --progress /vmfs/volumes/source_path/* user@x.x.x.x:/destination_path/ 39 | ``` 40 | ### rsync via SSH with SSHkey authentication (no password prompt) 41 | 42 | - SSH keys can be used to enable rsync to non interactively authenticate to the destination. Save the destination's private SSH key to a file in a *persistent* location and change the file's permissions with: `chmod 400 priv-key.txt` The below example uses SSH key auth to automatically login and begin sync (no password or other ssh prompts): 43 | ``` 44 | /productLocker/rsync -avurP --delete --progress -e "ssh -i /productLocker/priv-key.txt -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" /vmfs/volumes/source_path/* user@x.x.x.x:/destination_path/ 45 | ``` 46 | 47 | ### rsync to a local (or USB) Datastore 48 | See [here](https://github.com/itiligent/ESXi-Custom-ISO/blob/main/testlab-cheat-sheet.md#to-add-a-usb-backup-datastore-to-esxi) for instructions on adding a USB backup VMFS datastore. 49 | 50 | 1. Establish a new USB VMFS backup datastore (or confirm space in an existing datastore) 51 | 2. Create a backup destination folder on the destination datastore e.g. mkdir /vmfs/volumes/USB_datastore/full_backup_destination 52 | 3. Modify the below command to suit: 53 | 54 | /vmfs/volumes/USB_destination_datastore/rsync -rltDv --delete --progress /vmfs/volumes/source_path/* /vmfs/volumes/USB_datastore/full_backup_destination 55 | 56 | -------------------------------------------------------------------------------- /rsync: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itiligent/RSYNC-ESXi/fbd7e425ea040a72d5bd2165bf9ac7ce16cc7b4b/rsync -------------------------------------------------------------------------------- /rsync-esxi-compiler-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # To install Docker in Debian: 3 | # sudo apt-get update && sudo apt install curl docker.io python3 python3-pip -y 4 | # sudo usermod -aG docker $USER 5 | # Next START A NEW TERMIANL and run this script as sudo (new terminal refreshes Docker group permissions): 6 | # sudo ./rsync-esxi-compiler-docker.sh 7 | 8 | clear 9 | docker build . -t rsync-esxi 10 | docker run -d --name rsync-esxi rsync-esxi /bin/bash -c "while true; do sleep 30; done;" 11 | docker cp rsync-esxi:/rsync/rsync ~/. 12 | chmod 755 ~/rsync 13 | docker stop rsync-esxi 14 | clear 15 | echo "If build was successful, below output should state: 'not a dynamic executable:'" 16 | ldd ~/rsync 17 | echo 18 | echo "Testing new rsync binary..." 19 | echo 20 | cd ~ && ./rsync -V 21 | echo 22 | echo "The new rsync binary is located in the current dir." -------------------------------------------------------------------------------- /rsync-esxi-compiler.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #################################################################################################### 3 | # Compile RSYNC as a static binary for ESXi 4 | # YOU MUST BUILD THIS ON A CENTOS 7 SYSTEM 5 | # Check for latest version on github link below. 6 | #################################################################################################### 7 | 8 | # Instructions: 9 | # 1. Install a minimal Centos 7 virtual machine & give yourself administrator rights at install 10 | # 2. Copy this script to your Centos7 home directory 11 | # 3. Make script executable: chmod +x rsync-builder-centos7.sh 12 | # 4. Run the script (don't run as sudo, it will prompt for sudo): ./rsync-builder-centos7.sh 13 | 14 | clear 15 | 16 | # Prepare text output colours 17 | GREYB='\033[1;37m' 18 | LRED='\033[0;91m' 19 | LGREEN='\033[0;92m' 20 | LYELLOW='\033[0;93m' 21 | CYAN='\033[0;36m' 22 | 23 | NC='\033[0m' #No Colour 24 | 25 | RSYNC_VERSION=v3.4.1 26 | 27 | # Script header 28 | echo -e "${GREYB}Rsync for ESXi static binary compiler." 29 | echo -e ${CYAN} 30 | 31 | if [[ $EUID -eq 0 ]]; then 32 | echo -e "${LRED}This script must NOT be run as root, it will prompt for sudo when needed.${NC}" 1>&2 33 | echo 34 | exit 1 35 | fi 36 | 37 | # Now that CentOS 7 is EOL we need to change the repo links 38 | sudo sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/CentOS-*.repo 39 | sudo sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/CentOS-*.repo 40 | sudo sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/CentOS-*.repo 41 | sudo yum check-update 42 | 43 | # Install these first 44 | sudo yum -y install epel-release git lz4-devel lz4-static openssl-static python3-pip python3-devel glibc-static \ 45 | popt-devel popt-static make automake gcc wget doxygen rpm-build 46 | 47 | # Install these second 48 | sudo yum -y install libzstd-devel libzstd libzstd-static xxhash-devel 49 | 50 | # Install this third 51 | python3 -mpip install --user commonmark 52 | 53 | cd ~ 54 | mkdir ~/rpmbuild 55 | wget https://dl02.fedoraproject.org/pub/archive/epel/7/SRPMS/Packages/x/xxhash-0.8.2-1.el7.src.rpm 56 | rpm -ivh xxhash-*.el7.src.rpm 57 | cd ~/rpmbuild/SPECS 58 | rpmbuild -bp xxhash.spec 59 | cd ~/rpmbuild/BUILD/xxHash-*/ 60 | sudo make install 61 | 62 | cd ~ 63 | git clone https://github.com/WayneD/rsync.git 64 | cd ~/rsync 65 | git checkout $RSYNC_VERSION 66 | 67 | cd ~/rsync 68 | LIBS="-ldl" ./configure 69 | make -B CFLAGS="-std=c99 -static" 70 | 71 | echo -e "${LYELLOW}If build was successful, below output should state: 'not a dynamic executable'...${LGREEN}" 72 | ldd $(pwd)/rsync || true 73 | echo -e "${GREYB}The new rsync binary can be found in ~/rsync." 74 | echo -e ${NC} 75 | --------------------------------------------------------------------------------