rsync compares all files again and again

Elliot Wilen ewilen at mprinc.com
Fri Oct 14 14:36:54 MDT 2011


On Oct 14, 2011, at 11:37 AM, Elliot Wilen wrote:
> 
> Frank's idea seems to be valid, though: why not compare the mtimes of directories and skip comparing the mtimes & sizes of files in those directories which haven't changed?
> 
> Note 1: It looks like you'd still have to compare subdirs even if their parent dirs don't have a change in mtime.
> 
> Note 2: Frank mentioned ctime but I think mtime is what you need to look at.

About this, mtime on a directory doesn't change if only the content of a file within the directory changes. I was fooled by the fact that I was modifying a file (changing a single character) using vi. However, vi is actually writing a new file when it saves.

E.g.

% ls -i tmp
2669792 tmp.txt

ls -ld tmp
drwxr-xr-x  3 myname  staff  102 Oct 14 13:24 tmp

% echo hello >> tmp/tmp.txt

% ls -i tmp
2669792 tmp.txt

% ls -ld tmp
drwxr-xr-x  3 myname  staff  102 Oct 14 13:24 tmp

The last two commands confirm that tmp/tmp.txt is still the same file (and tail will show the appended "hello"), but the mtime of tmp/ hasn't changed.

So just comparing the mtime on directories to decide if their contents' mtimes need to be compared isn't going to work.

--Elliot Wilen


More information about the rsync mailing list