14

I am trying to sync a local path to another drive using Git Bash in Windows 7. I downloaded cwRsync and copied the files over to my Git bash bin directory. I can run rsync but the following command gives me problems

rsync -av /c/00-dev/05-batch /f/RSYNC/ The source and destination cannot both be remote. rsync error: syntax or usage error (code 1) at main.c(1135) [receiver=3.0.6]

Both the paths are correct but it won't sync.

Reptile
  • 353
  • 1
  • 2
  • 12

3 Answers3

14

Workaround: cd to /c and rsync using relative paths.

So this works:

cd /c
touch temp/test.txt
rsync temp/test.txt temp/test2.txt

while this doesn't, even if you cd to /c:

$ rsync /c/temp/test.txt /c/temp/test2.txt
The source and destination cannot both be remote.

Tested with the Git Bash that came with git 2.9.0.windows.1.

Jon Olav Vik
  • 1,421
  • 2
  • 12
  • 20
2

This works using cwRsync from Git Bash.

export MSYS_NO_PATHCONV=1
rsync -av /cygdrive/c/00-dev/05-batch /cygdrive/f/RSYNC/

cwRsync.exe needs /cygdrive/<drive-letter> for absolute pathing, so the simple rsync -av /cygdrive/c/00-dev/05-batch /cygdrive/f/RSYNC/ works from the cmd.

However, Git Bash converts paths like .../c/... to weird things like ...C:\.... The line: export MSYS_NO_PATHCONV=1 prevents that conversion. (See more: How to stop MinGW and MSYS from mangling path names given at the command line).

Use unset MSYS_NO_PATHCONV in the script to restore standard Git Bash behavior.

Liakos
  • 512
  • 5
  • 10
0

In Windows I tried cwRsync to sync data between folders located on Z:(network disk) and D:(usb stick) excluding a subfolder 'Data':

rsync -r -v --size-only --dry-run --exclude=Data --chmod=ugo=rwX /cygdrive/z/"Scan folder"/"Sub folder" /cygdrive/d/"Scan folder"/"Sub folder"

-r means recursively, -v verbose output, --dry-run is just for testing (data doesn't transfer), --exclude excludes subfolder or file(s), --chmod=ugo=rwX sets proper permissions (read more about permissions here with comments)

For cyrillic names on Windows use 'chcp 65001'.

Rapekas
  • 456
  • 7
  • 10