What is rsync?
rsync (remote sync)
is a tool for file synchronization. It can be used for file synchronization between two local directories, as well as between local devices and remote devices.
The difference between rsync and scp is that rsync checks the existing files on both the sender and receiver, transferring only the changed parts (the default rule is based on file size or modification time).
Using rsync
This demonstration uses a PC and a development board.
Note: Both sides of the transfer must have rsync installed.
Our development board does not have rsync, so let’s compile it together.
Download the rsync source code:
https://download.samba.org/pub/rsync/

Unzip, enter rsync-3.2.3, and create a tmp folder:
tar -xvf rsync-3.2.3.tar.gz
cd rsync-3.2.3/
mkdir tmp
Enter the following command to generate the cross-compilation Makefile:
./configure --prefix=$PWD/tmp --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc
You may encounter the following error:

Modify according to the prompt. It generally means that SIMD is enabled; we don’t need to worry about what SIMD is here, we can just disable it.
Output the command ./configure --help
to check the configuration parameters, and you can see how to disable SIMD as follows:

Input:
./configure --prefix=$PWD/tmp --disable-simd --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc
Still getting an error:

Modify the configure command again based on the prompt:
./configure --prefix=$PWD/tmp --disable-simd --disable-openssl --disable-xxhash --disable-zstd --disable-lz4 --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc
Now it shows rsync 3.2.3 configuration successful
:

The Makefile file can now be generated.
Note: If there are still errors, configure according to the prompts.
PS: You can refer to the previous article for support on the Makefile file: Basic Knowledge of Makefile!
Then compile and install:
make
make install
You will find it in the tmp folder:

Among them, the rsync executable file is what we need for our board. Transfer it to the board’s /usr/bin directory:
scp rsync [email protected]:/usr/bin

Next, let’s do a simple demonstration of using rsync:
Create 100 files on the board:

Synchronize these files from the board to the local PC:
rsync -avzu --progress [email protected]:/root/test .
-a: Archive mode, preserving all metadata like modification time, permissions, and owner. -v: Verbose output. -z: Compress data during synchronization. -u: Skip files that have been modified in the target directory. –progress: Show progress.


The board then creates another 100 files:

Synchronize again from the PC:

You can see that the files are transferred sequentially, and the previously transferred ones will not be sent again.
This concludes our brief sharing on the rsync tool.
Are there any other similar tools? Feel free to leave comments for discussion.