Carney Mimms
2008-Aug-20 14:38 UTC
How to escape spaces in rsync source and destination paths
This may not be an rsync-specific question, but it is certainly stopping me from moving forward with rsync and I am sure it has a simple solution. I have written a simple shell script to rsync disks attached to a Mac OS X Server 10.4.11 Xserve box at our offices to a similar Mac OS X Server 10.4.11 setup at our colocation facility. The script runs rsync 3.0.3 on the machine at the colocation facility but syncs the disks at our office back to its own disks, so DIRS is the path to the directory being backed up, which is remote, and BACKUP DIR is the path to the backup destination, which is on the machine running the script. The script works fine, except when I try to specify paths containing spaces. As you can see from the script excerpts below and the result, the backslash escape character isn't getting the job done and I can't figure out why. I've never had any trouble using the backslash escape in this way before. Can anyone suggest a different approach, other than renaming all my paths to eliminate spaces, which is the direction I seem to be heading :-) -------------------------------------------------------- DIRS="admin@192.168.100.47:/Volumes/Christine/Complete_Rug_Image_Archive/Lay ered\ Rooms/" BACKUPDIR="/Volumes/Paris/Complete_Rug_Image_Archive/Layered\ Rooms/" COMMAND="sudo /usr/local/bin/rsync $OPTS $EXCLUDES $DIRS $BACKUPDIR" result: Unexpected local arg: Rooms/ If arg is a remote file/dir, prefix it with a colon (:). rsync error: syntax or usage error (code 1) at main.c(1216) [receiver=3.0.3] ---------------------------------------------------------- -------------- next part -------------- HTML attachment scrubbed and removed
Wayne Davison
2008-Aug-20 15:24 UTC
How to escape spaces in rsync source and destination paths
On Wed, Aug 20, 2008 at 10:32:23AM -0400, Carney Mimms wrote:> COMMAND="sudo /usr/local/bin/rsync $OPTS $EXCLUDES $DIRS $BACKUPDIR"That's a sudo issue, since sudo runs the command and splits the args on spaces. You need to either add extra backslashes (\\\ for every \), add extra quoting (e.g. "'$DIRS'", which would only work for a single name), or put the source args into a file and use --files-from (with an explicit -r if you're expecting recursion). ..wayne..
Kyle Crawford
2008-Aug-20 15:31 UTC
How to escape spaces in rsync source and destination paths
On Aug 20, 2008, at 10:32 AM, "Carney Mimms" <Carney.Mimms@nourison.com> wrote:> This may not be an rsync-specific question, but it is certainly > stopping me > from moving forward with rsync and I am sure it has a simple > solution. I > have written a simple shell script to rsync disks attached to a Mac > OS X > Server 10.4.11 Xserve box at our offices to a similar Mac OS X Server > 10.4.11 setup at our colocation facility. The script runs rsync > 3.0.3 on the > machine at the colocation facility but syncs the disks at our office > back to > its own disks, so DIRS is the path to the directory being backed up, > which > is remote, and BACKUP DIR is the path to the backup destination, > which is on > the machine running the script. > > The script works fine, except when I try to specify paths containing > spaces. > As you can see from the script excerpts below and the result, the > backslash > escape character isn't getting the job done and I can't figure out > why. I've > never had any trouble using the backslash escape in this way before. > > Can anyone suggest a different approach, other than renaming all my > paths to > eliminate spaces, which is the direction I seem to be heading :-) > > -------------------------------------------------------- > > DIRS="admin@192.168.100.47:/Volumes/Christine/ > Complete_Rug_Image_Archive/Lay > ered\ Rooms/" > > BACKUPDIR="/Volumes/Paris/Complete_Rug_Image_Archive/Layered\ Rooms/" > > COMMAND="sudo /usr/local/bin/rsync $OPTS $EXCLUDES $DIRS $BACKUPDIR" > > result: > > Unexpected local arg: Rooms/ > If arg is a remote file/dir, prefix it with a colon (:). > rsync error: syntax or usage error (code 1) at main.c(1216) > [receiver=3.0.3] > ---------------------------------------------------------- >You haven't shown us the Rsync portion of your script. Are you using the protect args flag? Kyle -------------- next part -------------- HTML attachment scrubbed and removed
Yves PETRONIN
2008-Aug-22 15:05 UTC
How to escape spaces in rsync source and destination paths
On OSX 10.4.11 , I am using this for instance and it seem there is not problem with spaces in file names of Volume names. I did have problems originally, but after addig double quotes everywhere it worked fine. folderSourceToBackup="/Users/" VOLUMES="/Volumes/" backupVolume=${VOLUMES}"${NOMVOLUME}" exceptions="**/Caches/" destination="/Sauvegardes_hebdomadaires/" backupPath="${backupVolume}${destination}" for i in ${folderSourceToBackup}* do USERNAME=$(basename ${i}) echo -n "[*]: Starting backup of user ${USERNAME} to ${backupPath}" | logger rsync -aEv --delete --exclude=${exceptions} --delete-excluded ${i} "$ {backupPath}" 2 done
Reasonably Related Threads
- Some help with sudo on remote side of rsync
- Restoring deleted files.
- To inc_recurse or not to inc_recurse? [Re: 3.0.0pre2: bookend breakage (2 different errors)]
- imap - mailbox in an inconsistant state
- Is there a parameter in rsync to clean $BACKUPDIR before writing to it (--backup-dir=$BACKUPDIR)?