Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
/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
/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
/u/apps/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.

share|improve this question

migrated from serverfault.com Jan 24 '13 at 22:07

This question came from our site for professional system and network administrators.

add comment

1 Answer 1

up vote 2 down vote accepted

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
/home/bob/foo/bar

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

share|improve this answer
    
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 '13 at 19:29
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.