Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Need a one-time backup of two old messy Windows XP machines because of a company split. Using CentOS 6 x64 minimal install, i mounted some MS Windows NTFS harddrives installed locally via ntfs3g and over the LAN via smb. i need to self document what is backed up and thought there would be no better way than scripting everything done with rsync.

The problem is that almost all of the SOURCE folders have spaces in their name. The man page for rsync seems to indicate it supports only multiple source files, not multiple source folders. So i thought "easy enough", create a list and pass each source folder one-at-a-time to rsync.


SOURCEWITHSPACES=( "${PREFIX}/'Documents\ and\ Settings'/.  ${PREFIX}/'electronic\ claims'/.  ${PREFIX}/'billing\ statements'/." )
  do echo $P; 



So when this gets passed to rsync, it does not recognize any of the SOURCE folders. I do not want to glob because it needs to be clear exactly what was intended to be backed up. i also tried comma and colon separating the folder names, but that did not work either. What is the reliable way to handle this? Switch to perl or python? Please do not tell me to use robocopy.exe as i have used it for years and found it to differ so much between versions of windows, it is less reliable. Besides, i am never going back to Windows.


share|improve this question
Are you sure that combining ' and \ ('Documents\ and\ Settings') is a good idea? – Hauke Laging May 4 '13 at 20:02
Not sure, but i tried everything i could think of ... including putting in two \\ backslashes, thinking bash would escape one and rsync escape the other \. – rjt May 4 '13 at 20:05
Since the problem is that field separation is space character based in both sh and rsync, but the data contains space characters. i put in commas to separate the folders from the f o l de r s, but that did not work either. – rjt May 4 '13 at 20:08
up vote 2 down vote accepted

The shell script should be:

SOURCEWITHSPACES=( "${PREFIX}/Documents and Settings/." "${PREFIX}/electronic claims/."  "${PREFIX}/billing statements/." )
for P in "${SOURCEWITHSPACES[@]}";
    do echo "$P";
share|improve this answer
Thank You. had done this in years past and thought i had already tried your suggestion. Thank You. – rjt May 4 '13 at 20:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.