Skip to content

Instantly share code, notes, and snippets.

@dgleba
Forked from hisplan/add-rsync-to-git-bash.md
Last active August 23, 2021 08:25
Show Gist options
  • Save dgleba/3f6c8803487579a3c42af6746f93b9cb to your computer and use it in GitHub Desktop.
Save dgleba/3f6c8803487579a3c42af6746f93b9cb to your computer and use it in GitHub Desktop.
Add rsync to git bash for windows

How to Add rsync to Git Bash for Windows 10

Download the package: http://www2.futureware.at/~nickoe/msys2-mirror/msys/x86_64/rsync-3.1.2-2-x86_64.pkg.tar.xz

Extract it and move rsync.exe to %HOMEDRIVE%%HOMEPATH%\AppData\Local\Programs\Git\usr\bin.

code

open windows cmd prompt.. maybe an admin one..

cd %TEMP%
curl http://www2.futureware.at/~nickoe/msys2-mirror/msys/x86_64/rsync-3.1.2-2-x86_64.pkg.tar.xz -o rsync.txz
tar -xvf rsync.txz
cp usr/bin/rsync.exe "%ProgramFiles%\Git\usr\bin"

@dgleba
Copy link
Author

dgleba commented Oct 2, 2018

@rawhasan
Copy link

Looks like none of the links works! Any other link?

@complexgenome
Copy link

None of the links work.

@jeremysu0131
Copy link

Find the newer version in this link
http://repo.msys2.org/msys/x86_64/

@inspector71
Copy link

Does rsync function as a remotely accessible daemon when installed using this method?

@dgleba
Copy link
Author

dgleba commented Aug 16, 2021

It doesn't.

But I have been thinking of trying to use cygrunsrv installed by pacman.

The instructions are incomplete here...
https://github.com/dgleba/gitportable-pacman/blob/master/README__portable.git4windows.msys2.add.pacman..2021-08-07rsync.cygrunsrv.know.txt

I have used cygrunsrv in cygwin. I haven't tried it in msys2 yet. Below is how I have done it in cygwin. Maybe it will work in msys2.

:: copy rsyncd.conf and rsyncd.secrets  to c:\prg\cygwin64\rsync
   
:: In a admin cmd prompt:
   
set cygdg=c:\prg\cygwin64
set PATH=%cygpathdg%;%PATH%
::
cygrunsrv --remove  "rsyncd" 
::
cygrunsrv -I "rsyncd" -c "%cygdg%\tmp" -p "%cygdg%\bin\rsync.exe" -a "--config %cygdg%\rsync\rsyncd.conf --daemon --no-detach" -o -t auto -e "CYGWIN=nontsec binmode" -1 "%cygdg%\tmp\rsyncd-stdin.log" -2 "%cygdg%\tmp\rsyncd-stderr.log" -y "tcpip" -f "Rsync utility for file transfer cygwin"

:: get these two files from here: https://sourceforge.net/projects/backuppc/files/cygwin-rsyncd/3.1.2.1/
:: edit   rsyncd.conf
:: edit   secrets  -- rsyncd.secrets  

net stop rsyncd
net start rsyncd

:: open firewall for rsync.exe
netsh advfirewall firewall add rule name="rsync.exe" dir=in action=allow program="c:\prg\cygwin64\bin\rsync.exe"

@inspector71
Copy link

@dgleba Thanks! That is such an extensive, very helpful reply! Fanstatic.

Seems so strange after all these years when so many other critically useful nix-first binaries have Windows ports, there is still nothing simplistic for rsync. Oh well.

@dgleba
Copy link
Author

dgleba commented Aug 18, 2021

I did this and cygrunsrv worked. It makes an rsync deamon service that works.

This about:

download.. from.. https://github.com/git-for-windows/git/releases/tag/v2.32.0.windows.2
PortableGit-2.32.0.2-64-bit.7z.exe

https://github.com/dgleba/gitportable-pacman.git

  pacman -Sy rsync
  pacman -Sy cygrunsrv


#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#@  
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   2021-08-07[Aug-Sat]20-24PM 

11.

c:
md c:\temp
cd c:\temp

download..

from..
https://github.com/git-for-windows/git/releases/tag/v2.32.0.windows.2

PortableGit-2.32.0.2-64-bit.7z.exe

_____________

21.

Install 
PortableGit-2.32.0.2-64-bit.7z.exe
into folder
C:\prg\PortableGit\


_____________

=================================================


31.


Now add pacman package manager..


open git-bash terminal
   `C:\prg\PortableGit\git-bash.exe`


cd
mkdir bag
cd bag


  git clone https://github.com/dgleba/gitportable-pacman.git

  cd  ~/bag/gitportable-pacman

  bash install-pacman-git-bash.sh 2>&1| tee -a /c/temp/pacmanlog$(date +"__%Y.%m.%d_%H.%M.%S").txt


Install rsync and ..

  pacman -Sy rsync
  pacman -Sy cygrunsrv


#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#@  
#@  https://github.com/dgleba/gitportable-pacman.git
#@  
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   2021-08-07[Aug-Sat]20-11PM 

changes I made..


+rm -rf   /c/Users/david/bag/gitportable-pacman/git-sdk-64^M
+s=99 ; read  -rsp $"Wait $s seconds or press Escape-key or Arrow key to continue..." -t $s -d $'\e'; echo;echo;^M
+^M
 # Clone tiny blobless shallow repo
 git clone \
        --depth 20 \
@@ -18,9 +21,10 @@ git pull

 ### Pre install minimal pacman bootstrap
 d="var/lib/pacman/local"
-pkgs=('pacman-5' 'pacman-mirrors-' 'msys2-keyring-')
+pkgs=('pacman-6' 'pacman-mirrors-' 'msys2-keyring-')^M
 for j in ${pkgs[@]} ; do
-       pacvers=$(basename $( git show main:$d|grep "$j" ))
+       #pacvers=$(basename $( git show main:$d|grep "$j" ))^M
+       pacvers=$( git show main:$d|grep "$j" )^M
        echo $pacvers
        shfiles=$(curl -sSL $RAWURL/main/$d/$pacvers/files )
        for f in $shfiles
@@ -36,8 +40,9 @@ for j in ${pkgs[@]} ; do
         fi
        done
        wait
+  s=10 ; read  -rsp $"Wait $s seconds or press Escape-key or Arrow key to continue..." -t $s -d $'\e'; echo;echo;^M
 done
-wait
+wait^M

mkdir -p /var/lib/pacman


_____________


+++ git show main:var/lib/pacman/local| grep pacman-5


=================================================


>61.


rsyncd..
  
  
copy rsyncd.conf and rsyncd.secrets  to C:\prg\PortableGit\rsync

read rsync.conf to ensure the settings and paths make sense.

edit   rsyncd.conf
edit   secrets  C:\n\Dropbox\csd\0-csd\rsync,service,cygwin\rsyncd.secrets  
    
  
In a admin cmd prompt:
  
  
set cygdg=C:\prg\PortableGit
set PATH=%cygdg%\usr\bin;%PATH%
::
cygrunsrv --remove  "rsyncd" 
::
mkdir c:\temp
mkdir "%cygdg%\tmp"
cygrunsrv -I "rsyncd" -c "%cygdg%\tmp" -p "%cygdg%\usr\bin\rsync.exe" -a "--config %cygdg%\rsync\rsyncd.conf --daemon --no-detach" -o -t auto -e "CYGWIN=nontsec binmode" -1 "%cygdg%\tmp\rsyncd-stdin.log" -2 "%cygdg%\tmp\rsyncd-stderr.log" -y "tcpip" -f "Rsync utility file transfer msys2"


:: net stop rsyncd
net start rsyncd


_____________ 


open firewall for rsync.exe

  netsh advfirewall firewall add rule name="rsync.exe" dir=in action=allow program="C:\prg\PortableGit\usr\bin\rsync.exe"



test
  from another machine..

works..

passwd=x
user=david
srv=192.168.88.43
mkdir -p ~/.ssh
# set password..
pf=~/.ssh/pwf99
echo $passwd>$pf
chmod 700 $pf
rsync  -avvz -i --progress  --password-file=$pf $user@$srv::cDrive/Windows/regedit.exe  ~/tmp2/


=================================================


@inspector71
Copy link

inspector71 commented Aug 22, 2021

Wow, that is an incredible amount of work! Well done.

So rsync is available with PortableGit but not Git for Windows ?

Surely an 'extras' package that supports some of these needs could be a Git for Windows option. If only the authors of various Git distributions could combine their efforts! We could have the choice of:

Git for Windows (installer)
Git for Windows Extras (installer)
Git for Windows (portable)
Git for Windows Extras (portable)

Would not even necessarily need an install-as-a-service facility, as there's more than a couple of ways to install a program as a service on Windows.

Several, and I mean several, software projects do the above style of distribution. It's not unusual.

I did this and cygrunsrv worked. It makes an rsync deamon service that works.

...

This about:

download.. from.. https://github.com/git-for-windows/git/releases/tag/v2.32.0.windows.2
PortableGit-2.32.0.2-64-bit.7z.exe

...
=================================================

@dgleba
Copy link
Author

dgleba commented Aug 22, 2021

I installed portableGit, added pacman and then used pacman to install rsync. By adding pacman, I could install more than just rsync.

I think the same thing could be done with Git for Windows. I just prefer to use software that doesn't need admin permissions if that flavor is available.

@inspector71
Copy link

I installed portableGit, added pacman and then used pacman to install rsync. By adding pacman, I could install more than just rsync.

I think the same thing could be done with Git for Windows. I just prefer to use software that doesn't need admin permissions if that flavor is available.

Thanks for clarifying. Impressive that you have the patience for this effort 🤔

Uninstalled Git for Windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment