Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Would it be possible with rsync to adapt the absolute, symbolic links to a new location at the destination?

Test case
Imagine I have a link pointing to a file like this:

/usera/files/common/test_file
/usera/files/common/links/test_link -> /usera/files/common/test_file

Now I would like to rsync the whole directory common to another location. (group permissions are adapted, look below why)

rsync -av --no-g /usera/files/common/ /userb/common

That gives me:

/userb/common/test_file
/userb/common/links/test_link -> /usera/files/common/test_file

The problem
The problem is that the group on the destination is different than on the source (security reasons), so that the test_link does not point to /userb/ space but rather to /usera/ and therefore is not readable for this user.

Question
Would it be possible to tell rsync to adapt the links below the syncing point (/common/ here) to fit to the new destination? That would give a link as such:

/userb/common/links/test_link -> /userb/common/test_file

I tried following the solution to a similar problem, however it does not seem to do what I want..

Thanks!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Rsync does not support that. It could be modified to do so but rsync already has too many options. You could accomplish your goal by executing this after the rsync:

find /tmp/userb -type l -ls |
awk '$13 ~ /^\/tmp\/usera/ { sub("/tmp/usera/files/", "/tmp/userb/", $13); print $11, $13 }' |
while read A B; do rm $A; ln -s $B $A; done
share|improve this answer
    
Thanks a lot.That's a pity, though I do understand that rsync is overloaded. I will try your solution. –  ronszon Jan 20 '12 at 19:05

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.