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.

I have a large directory called servers, which contains many hard-links made by rsnapshot. That means that the structure is more or less like:

./servers
./servers/daily.0
./servers/daily.0/file1
./servers/daily.0/file2
./servers/daily.0/file3
./servers/daily.1
./servers/daily.1/file1
./servers/daily.1/file2
./servers/daily.1/file3
...

The snapshots were created with rsnapshot in a space-saving way: if /servers/daily.0/file1 is the same as /servers/daily.1/file1, they both point to the same inode using hard-link, instead of just copying a complete snapshot every cycle./servers/daily.0/file1/servers/daily.0/file1

I've tried to copy it with the hard links structure, in order to save space on the destination drive, using:

nohup time rsync -avr --remove-source-files --hard-links servers /old_backups

After some time, the rsync freezes - no new lines are added to the nohup.out file, and no files seem to move from one drive to another. Removing the nohup didn't solve the problem.

Any idea what's wrong?

Adam

share|improve this question

2 Answers 2

up vote 6 down vote accepted

My answer, which I give from hard-earned experience, is: Don't do this. Don't try to copy a directory hierarchy that makes heavy use of hard links, such as one created using rsnapshot or rsync --link-dest or similar. It won't work on anything but small datasets. At least, not reliably. (Your mileage may vary, of course; perhaps your backup datasets are much smaller than mine were.)

The problem with using rsync --hard-links to recreate the hard-linked structure of files on the destination side is that discovering the hard-links on the source side is hard. rsync has to build a map of inodes in memory to find the hard-links, and unless your source has relatively few files, this can and will blow up. In my case, when I learned of this problem and was looking around for alternate solutions, I tried cp -a, which is also supposed to preserve the hard-link structure of files in the destination. It churned away for a long time and then finally died (with a segfault, or something like that).

My recommendation is to set aside an entire partition for your rsnapshot backup. When it fills up, bring another partition online. It is much easier to move around hard-link-heavy datasets as entire partitions, rather than as individual files.

share|improve this answer
    
Plus one to that. You may also want to consider a different approach to the problem, like rdiff-backup, which uses binary diffs instead of hardlinks. (It's got some problems of its own, unfortunately.) –  mattdm Dec 1 '10 at 3:30
    
+1 Excellent answer, thanks. –  Adam Matan Dec 1 '10 at 9:23
1  
The hardlink program can search for identical files and hardlink them, but it requires them to all have exactly the same attributes (size, contents, permission, owner, group, etc) to work properly. I was able to use it to relink several tens of gigabytes of a music backup in about half an hour. –  zoqaeski Jul 7 '12 at 8:10
    
What do you mean by "blow up"? Exponential slowness? Or does an error occur to let you know that it's not going to work? –  Steve Pitchers Jul 22 at 11:16

At the point rsync seems to hang, is it hung or just busy? Check for cpu activity with top and disk activity with iotop -o.

It could be busy copying over a large file. You would see this in iotop or similar, or in rsync's display if you ran it with the --progress option.

It could also be busy scanning through lists of inodes to check for linked files. If incremental recursion is being used, which is the default for recursive transfers in most cases if both client and server have rsync v3.0.0 or later, it could have just hit a directory with many files and be running the link check between all the files in it and all those found previously. The --hard-links option can be very CPU intensive over large sets of files (this is why it is not included in the list of options implied by the general --archive option). This will manifest itself as high CPU use at the time rsync seems paused/hung.

share|improve this answer

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.