Solved

rsync commands on Windows paths with spaces

Posted on 2008-10-21
8
2,050 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
[X]
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
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

626 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