We do backups with rsync like this:
rsync -axH --inplace --delete --delete-excluded \
--exclude-from=excludes --stats \
--link-dest="${previous?}" "${source?}"/ "${dest?}"/"${stamp?}"
$previous points to the previous backup, so that unchanged files will be created using hardlinks. The destination filesystem $dest is on an external USB hard drive with nothing else on it than the collection of backups.
This method is amazingly fast in most of the cases. On the test system, each backup is about 200 GB and contains some big maildirs - still the whole rsync (provided that not much was changed since the last run) takes only around a minute.
However, in rare cases, maybe every 100 runs on average, it takes very long, around 20 minutes or longer. The rsync statistics show nothing unusual. The host system shows no unusual activity during such runs. Nothing exciting in syslog.
It appears to be worse on some filesystems (for $dest) than on others. The above figures are for EXT4. On JFS for example, the normal runs take about 3 minutes and the exceptional runs are less severe, but still a problem for us.
A look at rsync's debug output reveals that during the long runs, certain (large) files are found to be not uptodate, although they have not been changed on the sender. No hardlinks are created for those files, as a look at their inode reveals. But rsync's statistics do not show more transferred bytes than usual, and from observing the hard disk activity LEDs, only the destination drive is working in those cases. Are those files copied on the destination from one directory to the other? This is turning out not only to be a perfomance problem, but could lead to unnecessary space consumption, too.
In case it matters: directly before the backup, the oldest of the existing backups is deleted using:
rsync -a --delete empty/ "${dest?}"/"${old?}"
where 'empty' is an empty directory. This is much faster than 'rm -fr'.
Could anyone please offer possible explanations for this and perhaps a cure?
Using rsync version 3.1.0 protocol version 31.