Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to sync files via rsync and let rsync only compare mtime informations?

Or is there another tool for this job?

That means that such a tool only copies src to destination if the src is newer than the destination. Comparable to GNU cp --update - but also over ssh ...

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Yes, it is possible. rsync also has --update, but with it rsync still uses its delta-transfer algorithm in case the src is newer. rsync provides the --whole-file option to disable this algorithm. Thus,

$ rsync --update --whole-file ...

should have the effect that src files are only copied to the destination when they are newer. And only mtime checks should be used for this.

There are several reasons to avoid the delta-transfer algorithm for special use cases. Mainly performance reasons and perhaps transfer volume in very special cases.

To quote from the man-page:

-W, --whole-file

With this option rsync’s delta-transfer algorithm is not used and the whole file is sent as-is instead. The transfer may be faster if this option is used when the bandwidth between the source and destination machines is higher than the bandwidth to disk (especially when the "disk" is actually a networked filesystem). This is the default when both the source and destination are specified as local paths, but only if no batch-writing option is in effect.

The case about networked filesystems should be the most common one.

Also, since the delta-transfer algorithm is a heuristic you can imagine files where the algorithm ends up transferring the whole file and just adds (time and space) overhead.

share|improve this answer
1  
I don't understand why --update (-u) alone isn't enough. –  Gilles Nov 23 '11 at 22:06
1  
If you want to get the exact same behavior as cp --update, you'd need to transfer the whole file. Although I know of no reason why you wouldn't want to speed-up your transfers. –  Gert Nov 24 '11 at 5:35
    
@Gert, @Gilles: updated the answer and added a motivation for --whole-file. –  maxschlepzig Nov 24 '11 at 9:04

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.