简体   繁体   中英

rsync (cwrsync) in Gitbash - The source and destination cannot both be remote. [windows 7]

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.

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 .

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'.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM