Solved

rsync commands on Windows paths with spaces

Posted on 2008-10-21
8
1,990 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
My previous article  (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/A_4466-A-beginners-guide-to-installing-SCCM2007-on-Windows-2008-R2-Server.html)detailed one possible method to get SCCM 2007 installed an…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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