Rsync: escaping spaces in directories or files
August 21, 2007 - Gyuri van de BiltWhen using rsync to backup files, you may want to backup directories with spaces in the path. Several sources give alternatives on how to properly escape the spaces. Different uses of rsync require different ways of escaping…
Error
When not using the proper way to escape the spaces, you probably see an error like this:
building file list … rsync: link_stat “/Users/…/Library/Application Support/” failed: No such file or directory (2)
Solutions
The following are commonly discussed solutions for escaping spaces:
- rsync -av host:’”a long filename”‘ /tmp/
- rsync -av host:’a\ long\ filename’ /tmp/
- rsync -av host:a\\\ long\\\ filename /tmp/
- rsync -av host:a?long?filename /tmp/
The last option above only work if there is no other directory that matches the wildcard(s) (’?’ is a wildcard).
The first three options seem to work in some cases. However when using a script that reads the directories to backup from a file (not using ‘–files-from’ which is in the man pages of my Mac, but doesn’t seem to work; so instead using `cat folders.cnf`), the only option that worked was using the wildcard ‘?’. In different cases, you may want to try all (or even combinations) of the options above.
Comments»
no comments yet - be the first?