Solved

rsync commands on Windows paths with spaces

Posted on 2008-10-21
8
1,978 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
 

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
Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The question has been asked on multiple occasions as to how best to do printing in a remote desktop or terminal services environment.   It seems that this particular question has plagued several people and most especially as Terminal Services, as…
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 is around source server preparation. No migration is an easy migration, there is a…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now