Rsync claims different files, but diff does not

diff()rsync

I have a file both locally and on server. I first try running rsync in "dry-run" mode, to see if there are some differences between the files:

$ rsync -aP --dry-run USER@192.168.0.55:/home/dir .
USER@192.168.0.55's password: 
receiving incremental file list
dir/myfile.txt

This apparently means that the file dir/myfile.txt is different, as it would be updated. Then I check the same files with a diff:

$ ssh USER@192.168.0.55 'cat /home/dir/myfile.txt' | diff --report-identical-files - dir/myfile.txt
USER@192.168.0.55's password: 
Files - and dir/myfile.txt are identical

So, the files are identical, apparently.

Why does then rsync want to update this file – and how could I confirm the reason from the command line?

Best Answer

rsync will report changes for

  • permissions differences
  • timestamp differences
  • content (and filesize) differences

In comments, @roaima pointed out that there is an option to give a summary of these changes, in the rsync manual page:

-i, --itemize-changes       output a change-summary for all updates

You may find it useful, though the summary is terse and (in the version I have at hand) only reports the type (file, link or directory) and name. Here is what I see with rsync 3.0.9-4 and 3.1.1-3 on my Debian 7 and testing machines:

cd+++++++++ backup-invisible-island/
>f+++++++++ backup-invisible-island/.bash_history
cL+++++++++ backup-invisible-island/conf -> ../system/invisible-island.net/conf
cL+++++++++ backup-invisible-island/statistics -> ../system/invisible-island.net/statistics
cd+++++++++ backup-invisible-island/anon_ftp/
cL+++++++++ backup-invisible-island/anon_ftp/AdaCurses -> pub/AdaCurses
cL+++++++++ backup-invisible-island/anon_ftp/DEBS -> pub/DEBS
cL+++++++++ backup-invisible-island/anon_ftp/GIT -> pub/GIT

For my own use, changes of timestamps for directories are relatively unimportant. I use a script which shows only files which are changed:

rsync: show when newer file on destination is to be overwritten

Related Question