7

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 [email protected]:/home/dir .
[email protected]'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 [email protected] 'cat /home/dir/myfile.txt' | diff --report-identical-files - dir/myfile.txt
[email protected]'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?

4 Answers 4

7

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

3
  • 1
    Many thanks @ThomasDickey - is there a way to check which of these is the actual reason for rsync to want to do an update from the command line?
    – sdbbs
    Jun 30, 2016 at 8:59
  • I haven't seen an option for doing this. Jun 30, 2016 at 9:08
  • 3
    @sdbbs add the --itemize-changes (or -i) flag. It will report a summary of the set of changes required. In my own scenario it shows >f..t...... for two files that are the same apart from the file timestamp Jun 30, 2016 at 9:46
1

Rsync synchronizes files unless it is able to decide that they're the same without comparing their contents. It might synchronize a file and realize that there aren't any differences, if it wasn't able to tell that the files are identical without checking the contents.

By default, rsync decides that two files are identical (and thus skips reading their contents) if they have the same size and the same timestamp.

The most common reason for two files being treated as different when they're identical is that they have identical contents, but different timestamps, because the file was copied in the past and the timestamp on the copy is the date of the copy rather than the timestamp of the original file. For example, the file might have been copied with scp without -p, with rsync without -p or -a, downloaded by a web browser, etc.

If the timestamps are different then rsync needs to synchronize the file anyway since you told it to synchronize metadata (-a). So the listing in rsync -n is perfectly justified: rsync has work to do. Synchronizing the time is a good idea anyway because it's the only way to arrange that future runs of rsync will know that there's nothing to do.

0

Just a note on the previous answers -- if you find rsync repeatedly reporting the same file(s) as changed it is most likely a timestamp issue -- some filesystems (most notably FAT) store timestamps with less precision so rsync may fail to set the same timestamp if syncing between different filesystems.

0

First of all, find out why. just do $ls -lau and check permissions and time stamp differences. If they are different then this is the problem and you should just pass -p to copy permissions and -t to copy with time stamp.

As for your usage, it seems that you are backing up your data regularly. A program called "Timeshift" does a perfect job at such thing but it unfortunately doesn't officially support remote backups but check this suggestion for a workaround.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .