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.

On the source server (A), I got a file /opt/resources/xxx and a hard link /etc/apache2/sites-available/xxx pointing to this file.

On another server (B) I got the same structure /etc/apache2/sites-available/xxx hard linked to /opt/resources/xxx

I rsync on server (A) towards server (B) all changes under /opt

When I change file xxx on server A, and then rsync to server B these changes are reflected. /opt/resources/xxx on server B contains my changes I made on the same file on server A.

The only thing I don't understand is that the file /etc/apache2/sites-available/xxx doesn't contain the change.

It appears as if rsync breaks the hard link, but probably I'm missing some configuration option.

Which one ?

Francis

share|improve this question
add comment

2 Answers

-H is the option for preserving hard links; it is not included in -a.

share|improve this answer
add comment

rsyncs handling of hardlinks depends on you sending ALL linked files in a single transfer (syncing both /etc/apache2/sites-available/ and /opt/resources/ to server B at once):

Note that rsync can only detect hard links between files that are inside the transfer set. If rsync updates a file that has extra hard-link connections to files outside the transfer, that linkage will be broken.

This is because by default, rsync writes the file to a new location then moves it over the top of the previous file, essentially erasing the original hard link and replacing it with a new file. It suggests using the --inplace option to change this default, but warns that there are risks to that, most notably:

(2) the file's data will be in an inconsistent state during the transfer, (3) a file's data may be left in an inconsistent state after the transfer if the transfer is interrupted or if an update fails

share|improve this answer
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.