Skipping hardlinks in a copy

Eur Ing Chris Green cl at
Thu Mar 8 08:56:58 GMT 2007

On Wed, Mar 07, 2007 at 09:22:08PM -0800, Sriram Ramkrishna wrote:
> Hi folks, I've been googling around for awhile but I can't seem to find
> an answer to my question. 
> I have a number of filesystems that contain thousands of hard links due
> to some bad organization of data.  Rsync, cpio and various other
> utilities fail to copy this data because I think there might be some
> cycles in it.  (you know you have troubles if cpio can't copy it!)
> What I thought I would do instead is to copy the data but skip any files
> that are hard links.  Then after the copy is finished, I will use some
> kind of find . -type l type command that finds the hard links and then
> make a script to recreate it.  This saves me a lot of trouble with not
> having to stat the files and not having the receive side balloon up.
> Is there a way to have it skip hard links when doing an rsync?
> Or is there some other mystic incantation that I can use that might
> accomplish the same thing.
Surely a hard link is just 'a file', that's what a file is, thus it's
impossible to skip them without skipping everything (except symbolic
links, FIFOs, etc).  The only clue to something having more than one
link to it is the 'number of links', but then how do you decide which
link is the 'right' one to copy as they're all the file.

Chris Green

More information about the rsync mailing list