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

When I do rsync --dry-run -rv, rsync is listing files that are identical except for their timestamps.

My understanding was that with just these flags (which don't really change the comparison behavior), rsync would see the differing timestamps, check the file sizes (which are, of course, the same), and then finally do a checksum on the files, before flagging them for update. If the checksums match up, even if the timestamps are different, the file would not be updated.

What am I misunderstanding?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

It seems like you understand things just fine with one exception. When you are in --dry-run mode rsync doesn't compute the checksums so you might see files that would not be transferred after the checksum is done.

Because the timestamp is different rsync knows that it will be updated, but since it is in dry-run mode it won't be able to report that the only thing that needs to be updated is the timestamp.

I'm using it to monitor failure of synchronization between remote machines... so it's really just a remote diff.

I don't know how to force a checksum in dry-run mode.

Since it sounds like you are trying to force a comparison of a local and remote set of synchronized files, then you might want to try something like this instead? (sha256deep can be replaced with sha1 or md5 deep if you want more speed).

diff -u <( /usr/bin/sha256deep -l -z -r -o f path | sort -k 3 ) \
        <( ssh remote /usr/bin/sha256deep -l -z -r -o f path | sort -k 3 )`

That command would calculate the md5 checksum for each file both locally and remotely. The two lists are sorted on the path, and diff will show you and differences in the checksums.

share|improve this answer
    
That would explain it, but I couldn't find documentation of that behavior--could you point me to any? Here's what the man page says for --dry-run: "This tells rsync to not do any file transfers, instead it will just report the actions it would have taken." By that it would have been reasonable to assume that the comparison behavior would be unchanged--just the transfer and modification of data. –  dlo Jul 11 '12 at 20:52
    
Anyway, do you know of a way to override this behavior and force a checksum, not of everything, just files with different timestamps? –  dlo Jul 11 '12 at 20:52
    
Is there some reason why you don't simply remove the --dry-run option and let it do the sync? –  Zoredache Jul 11 '12 at 21:06
    
I'm using it to monitor failure of synchronization between remote machines... so it's really just a remote diff. –  dlo Jul 11 '12 at 22:47
1  
I read the rsync man a bit more carefully and came across the --size-only option. Without it I'm getting false-positives when the files are the same but the timestamps aren't (which happens quite a bit). With it, I suppose I can get false-negatives where the sizes are the same but the files aren't. I need to think if my situation can tolerate that possibility. I think it's probably a very unlikely occurrence, so probably ok. I have a feeling all of this discussion will prove helpful to someone else someday. Thanks again. –  dlo Jul 12 '12 at 4:02
show 4 more comments

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.