Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

SCRIPT:


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

OUTPUT:

/media/4EC75/'Documents\
and\
Settings'/.
/media/4EC75/'electronic\
claims'/.
/media/4EC75/'billing\
statements'/.

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.

TAG=spacesinfolderfilenames

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
add comment

1 Answer 1

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";
done
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
add comment

Your Answer

 
discard

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.