?
Solved

rsync commands on Windows paths with spaces

Posted on 2008-10-21
8
Medium Priority
?
2,083 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

718 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