Exclude symbolic link to a directory?
wayned at users.sourceforge.net
Thu Oct 10 17:39:00 EST 2002
On Thu, Oct 10, 2002 at 10:49:33AM -0400, Bryan K. Wright wrote:
> The master copy of /local contains the directory "stuff", not
> a symbolic link. The problem is, when I rsync /local on the few
> machines that have a symbolic link, the link gets nuked and replaced
> with a real directory (just like in the master copy).
Correct. That's the only thing that rsync currently knows how to do
with symlinks to directories -- make them identical with what's on the
server. The easiest way around this at the moment is to break up the
rsync command into multiple runs, one which excludes all the potential
symlink differences, and one for each symlink dir that you want to
> What I've tried is excluding "/local/stuff" and including
> "/local/stuff/*", but the stuff symlink still gets nuked.
I don't think you were successful at getting the dir excluded, then, or
else it would have been untouched, not nuked. Rsync would not have done
what you wanted, though, since it has to send the /local/stuff dir to
try to send what's inside it (when working recursively). You probably
did an exclude of "/local/stuff" rather than "/stuff" (since I assume
that the base dir is probably "/local").
So, a solution like this should work:
rsync -av --exclude="/stuff" /local/ remote:/local
rsync -av /local/stuff/ remote:/local/stuff
A better, long-term fix would be to add an option that would allow
certain symlinks to be treated as a directory. To do this, we need to
work out a good heuristic on how to differentiate which is which. I
imagine using the following rules (when the new option is enabled):
- If a symlink points inside the hierarchy being transferred, treat it
as a normal symlink to duplicate (rsync already has code to determine
this for its "safe symlink" handling).
- If a symlink points outside the transfer AND it points to a
directory, treat it as if it were the actual directory for the
transfer (I think that only the delete code would need to know that
it wasn't a real directory).
How does that sound? It should be fairly easy to implement.
More information about the rsync