I've pored over the rsync manpage as well as on several related questions here on serverfault. I've played with -R and -L and -l options, but no luck.

Here is the question: when sending a dir from local to remote, is there an option (or option combo) that relocates symlinks relative to the local dir so that they become relative to the destination dir on the remote machine?

Here is a minimal example of what I want to send:

local dir: /home/bob/foo

/home/bob/foo/a --> /home/bob/foo/bar

and here is how I would like it to materialize in the

remote dir: /u/apps/foo

/u/apps/foo/a --> /u/apps/foo/bar

For example, rsync -az /home/bob/foo/ remote:/u/apps/foo/ doesn't quite do it; we end up with:

/u/apps/foo/a --> /home/bob/foo/bar

Whether /home/bob/foo/bar exists or not on the remote machine is irrelevant; in either case, the result is definitely not what I need.

1 Answer 1


If the links are to absolute paths, no there's no way around it. You can get around it by making the symlinks relative:

/home/bob/foo/a --> ./bar

but that may prove difficult, depending on how you generate those links and how many of them there are.

  • Thanks, this is great. I didn't realize the symlink was absolute, I thought it was just an effect of the way it was listed. After making the links relative, it all works out. Next I'll think of a way to trawl the directories and relocate all the absolute symlinks found if they can be made relative to the topdir (in the example /home/bob/foo). Should be a perl one-liner.
    – Pierre D
    Jan 25, 2013 at 19:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .