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

according to rsync command - MAN page:

#

-a, --archive This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is not implied.

Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify -H.

#

it's seems that we must use -H flag in order to copy also the hard links (realy?)

but according to my tests even if I not use the -H flag in rsync command the hard link copied successfully from local directory to other machine ? (very strange ?)

for example

ls -ltr

    -rw-r--r-- 1 root root 0 Jan 20 15:06 test.file.hard.link
    -rw-r--r-- 1 root root 0 Jan 20 15:06 test.file

    rsync -Wav   --progress /var/tmp/Backup_test_for_hard_link node1:/var/tmp

in node1 under /var/tmp I see the hard links files:

    -rw-r--r-- 1 root root 0 Jan 20 15:06 test.file.hard.link
    -rw-r--r-- 1 root root 0 Jan 20 15:06 test.file

please advice how it can be ?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Those two are not hardlinks, as the link count would have be 2 if they where indeed links.

Also, if a file was existant with two hard links and you don't use the -H option, rsync would just create two copies of the file, while the additional (expensive) logic of the -H option would recognize that the two files are in reality only one and recreate them accordingly.

To illustrate it:

Source dir (note the link count 2):

total 0
-rw-r--r-- 2 root root 0 Jan 20 13:37 myfile
-rw-r--r-- 2 root root 0 Jan 20 13:37 myfile2

Target dir after rsync -Wav --progress t1/* t2 (note the link count 1):

total 0
-rw-r--r-- 1 root root 0 Jan 20 13:37 myfile
-rw-r--r-- 1 root root 0 Jan 20 13:37 myfile2

Target dir after rsync -WavH --progress t1/* t3 (note the link count is 2 again):

total 0
-rw-r--r-- 2 root root 0 Jan 20 13:37 myfile
-rw-r--r-- 2 root root 0 Jan 20 13:37 myfile2
share|improve this answer
    
According to you experience did the command (rsync -WavH –progress) Can copy the same files exactly from source to target ? or I need to add some other flags to rsync command? , my target to copy large directories withe many files from source machine to target machine –  yael Jan 20 '11 at 13:47
    
I normally wouldn't use the -W and seldom the -H option (since I don't need it), but other than that rsync is rock solid and I use it daily to keep many TBs of data in sync, ranging from a few MBs of files to 14TB in ~2 million files. What other options you need depend on your usage (i.e. do you need ACLs and other extended attributes? Do you want to follow symlinks?). Tell us a bit about a bit more about your situation so we can help you better. –  Sven Jan 20 '11 at 14:16
    
OK well, my target is to copy EMC storage partition - usage like 10G-20G , and I have system Red-hat cluster Linux , so need to copy all directories & files & links & symbolic links and so on .... –  yael Jan 20 '11 at 14:38

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.