So, I start with comparing two directories:
[root@135759 ]# rsync -av test1/ test2/
building file list ... done
sent 128 bytes received 20 bytes 296.00 bytes/sec
total size is 6 speedup is 0.04
They both are in sync Now, let me create a file in test1 and copy it to test2
[root@135759 ]# touch test1/hello4.php
[root@135759 ]# scp test1/hello4.php test2/hello4.php
I verify that those are same:
[root@135759 test2]# md5sum test1/hello4.php
d41d8cd98f00b204e9800998ecf8427e hello4.php
[root@135759 test1]# md5sum test2/hello4.php
d41d8cd98f00b204e9800998ecf8427e hello4.php
Thus, running rsync will show me 0 files. Why is the output not right ?
[root@135759 ]# rsync -avn test1/ test2/
building file list ... done
hello4.php
sent 116 bytes received 24 bytes 280.00 bytes/sec
total size is 6 speedup is 0.04
The file contents are the same, so rsyinc is sending very little data. But I suspect that some of the metadata on the files is different. I am guessing creation versus modified timestamps maybe based on your example. Check those before running rsync the second time. When rysnc sees differing timestamps, it does do a "transfer" of that file, even if no file data is involved, and only metadata.
rsync by default does 'quick' comparisons by file mtime and size; even local clock drift can sometimes cause problems with this, so if you really need to know that the files are absolutely identical before deciding to skip them for transfer, use rsync's
--checksum
option, which will checksum the file on each end and compare the results. Be forewarned that for operations involving large files, or many files, or both, that this option can be very CPU intensive and increase the time required to sync considerably.