Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

rsync commands on Windows paths with spaces

Posted on 2008-10-21
8
2,007 Views
Last Modified: 2013-12-05
I am experimenting with rsync on two windows server and am able to get rsync to work well but have a weird problem with paths with spaces.

I am trying to mirror a directory that has automated SQL backups with the following command. I should point out that I have tried various combinations of quotes and escape chars with this command.

rsync -av 192.168.0.1:"/cygdrive/c/Program\ Files/Microsoft\ SQL\ Server/automated\ backups" /cygdrive/c/Program\ Files/Microsoft\ SQL\ Server/automated\ backups

The weird part is that this command works when I run it in the cygwin console, but returns the following error when run as a bat file or in cmd.exe

rsync -av -W 192.168.0.1:"/cygdrive/c/Program\ Files/Microsoft\ SQL\ Server/automated\ backups" /c
ygdrive/c/Program\ Files/Microsoft\ SQL\ Server/automated\ backups
Unexpected local arg: /cygdrive/c/Program\
If arg is a remote file/dir, prefix it with a colon (:).
rsync error: syntax or usage error (code 1) at /home/lapo/packaging/rsync-3.0.4-
1/src/rsync-3.0.4/main.c(1216) [receiver=3.0.4]

0
Comment
Question by:excelsupport
  • 4
  • 4
8 Comments
 
LVL 4

Expert Comment

by:petr_hlucin
ID: 22765881
Isn't this a rights issue? I use rsync between 2 servers (one-way synchronization) in the following scenario:
On the server where the production data are there is just a scheduled task executing:
"C:\Program Files\cwRsync\bin\rsync" --append --delete --ignore-errors --size-only -r --password-file="/cygdrive/c/program files/cwRsync/passwd" "/cygdrive/e/LogBase/" rsync://hostname:873/LogBase

On the server where I synchronize to there is cwRsync server running which has LogBase resource. Probably this scenario would solve your problem.
0
 

Author Comment

by:excelsupport
ID: 22765981
Why would permissions throw up what looks like a misinterpreted path at a space?

Unexpected local arg: /cygdrive/c/Program\

And why does this work when executed in the cygwin bash shell but not in the windows cmd shell?
0
 
LVL 4

Expert Comment

by:petr_hlucin
ID: 22767211
Oh, now I see the problem - the path is not quoted. Execute it as below.
rsync -av 192.168.0.1:"/cygdrive/c/Program\ Files/Microsoft\ SQL\ Server/automated\ backups" "/cygdrive/c/Program\ Files/Microsoft\ SQL\ Server/automated\ backups"

Open in new window

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:excelsupport
ID: 22767359
No that doesn't work. I have tried various ways of escaping and quoting the path spaces.

I can get the command to work (with more than one syntax or quotes and escape chars) when run in the cygwin bash shell, but it throws the path error when run in windows cmd shell...

I will be scheduling the commands as batch files so they need to run in windows cmd shell. Most of the commands do work as expected, but this one with spaces in the path doesn't...
0
 
LVL 4

Expert Comment

by:petr_hlucin
ID: 22790815
How do you execute it? As a batch file, or directly as scheduled task? I execute it as a batch file without any problem.
0
 

Author Comment

by:excelsupport
ID: 22794780
As a batch file.
0
 
LVL 4

Expert Comment

by:petr_hlucin
ID: 22807902
Redirect stdout to a file to know what is the problem. Or there should be a log on the server side. What`s in it?
0
 

Accepted Solution

by:
excelsupport earned 0 total points
ID: 23011508
I gave up on rsync on windows and am using robocopy which seems to do the job.

I never did find a solution to my rsync problem.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found here: http://www.experts-exchang…
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question