19

I'm trying to run rsync on Windows with the cwrsync port.

I'm issuing the following command (note that this is just a dry run):

rsync -nPaAz [email protected]:/home/foobar/webapps/barbaz/ C:\\mybackupfolder\

but I get the following error

The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at main.c(1148) [Receiver=3.0.8]

Could someone point me in the right direction?

4 Answers 4

23

For the destination try using:

/cygdrive/c/mybackupfolder/

Note that a colon tells rsync that the location is remote.

3
  • Gotcha about the colon! But it doesn't seem to help. Tried this other version (%CD% is an env variable pointing to the current dir) too but still failing: rsync -nPaAz [email protected]:/home/foobar/webapps/barbaz/ %CD%
    – Lorenzo
    Sep 20, 2011 at 22:38
  • 2
    what about changing to the destination directory and then just use "." for the destination?
    – jftuga
    Sep 21, 2011 at 2:30
  • This actually works for me. You can just prepend /cygdrive/ before any windows drive. I installed rsync through Chocolatey (therefore cygwin based).
    – seb
    Aug 8, 2019 at 11:36
8

My environment: Windows 10, in powershell. Solution also worked in a DOS prompt.

The problem is caused by the : after the drive letters, which makes it look like a hostname specification. You have to use an alternative notation.

I was using rsync installed via Chocolatey, so no cygwin drives.

Windows 10 lets me do this on powershell:

dir //localhost/C$

so, this command, run in a Windows 10 powershell, worked just fine for me, after running into same exact problem.

rsync -av //localhost/d$/home/work/fb460.winbup/src //localhost/d$/home/work/fb460.winbup/tgt
2
  • Note this doesn't work or at least I couldn't make it work for ext2fsd drives. Your experience might differ. However as I wanted to copy from ext2 to ntfs I just changed to the ext2 drive and ran rsync -a some/path //localhost/c$/some/path
    – chx
    May 2, 2017 at 9:20
  • I also installed via Chocolatey. This worked well for me! NTFS to NTFS. Jan 6, 2018 at 22:33
5

Got here from a similar problem with rsync for Windows.

Instead of using the path, just make a .bat file that uses CD C:\whereto\ then in the rsync command just use . as the directory to save to.

Example (something.bat):

@echo off  
cd C:\mybackupfolder\  
rsync -nPaAz [email protected]:/home/foobar/webapps/barbaz/ .  
2

Try

 rsync -nPaAz [email protected]:/home/foobar/webapps/barbaz/ C:/mybackupfolder/
3
  • This does not work as expected for me. Apr 29, 2012 at 22:54
  • @EmreYazici What did you expect?
    – Marki
    Mar 10, 2021 at 17:19
  • @Marki Whatever the expectation, that was nine years ago :)
    – Krumelur
    Mar 12, 2021 at 8:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .