Add rsync to Windows git bash
Utilizing power of rsync inside git bash
Rsync
Remote sync or most known rsync is one of the most popular tools among linux/unix community for copying and synchronizing files and folders remotely as well as in local systems. This is a trusted tool for mirroring data, backups, copy files in between many distributed systems, mainly because rsync offers features like greater transfer speeds, incremental updates, and preserved attributes.
Recently there was a specific requirement to synchronize one of the local git repositories to a special backup folder in another server in a windows environment. Even though this is a perfect job for rsync, it's not available for git bash environment in windows unlike curl
, vim
, ssh
, git
, grep
orfind
commands.
Adding rsync to Windows git bash is not very straight forward. Especially since, it does not come with a package manager. Hence thought of sharing my experience which might make life easier for few who travel down the same route.
Prerequisites
- Git for Windows v2.28.0 or higher
Download rsync
First requirement is to download a compatible rsync package. Git for Windows is based on MSYS2 and hence a compatible rsync package can be downloaded from MSYS2 package repository.
https://repo.msys2.org/msys/x86_64/rsync-3.2.3-1-x86_64.pkg.tar.zst
However this package uses ZStandard compression algorithm. This will require zstd command line utility to decode the rsync package.
zstd -d rsync-3.2.3–1-x86_64.pkg.tar.zst
Copy the rsync package to Git for Windows
Copy the rsync.exe inside the package from rsync-3.2.3–1-x86_64.pkg\usr\bin\ to C:\Program Files\Git\usr\bin\
Now rsync can be accessed from Windows git bash. However there are still few dependent packages are needs to install using the same mechanism.
Download and copy the dependent packages
Following are the dependent packages required for the rsync package to work within Windows git bash.
Package: libzst
https://repo.msys2.org/msys/x86_64/libzstd-1.4.7-1-x86_64.pkg.tar.xz
Package: libxxhash
https://repo.msys2.org/msys/x86_64/libxxhash-0.8.0-1-x86_64.pkg.tar.zst
.. and Voilà— Now rsync can be used from Windows git bash
Please let me know if this post is helpful or how this can be improved further.
Merry Christmas and happy coding!