Lasse Kliemann
2008-Mar-04 11:17 UTC
preserve ctimes of *unchanged* directories on receiver
'rsync -a' updates the ctime on a directory even if no file in that directory has changed. A kind of workaround is to use '-O', but then the mtimes of directories are not preserved. (Usage example where this is important: maintain a copy of filesystem A in filesystem B, and use filesystem B as the source for incremental backups (e.g., with star). rsync is run before an incremental backup is made. Because of the above described ctime problem, every incremental backup will contain *all* directories, even if filesystem A was not changed since the last sync and backup.) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available Url : http://lists.samba.org/archive/rsync/attachments/20080304/29de1383/attachment.bin
Wayne Davison
2008-Mar-05 06:24 UTC
preserve ctimes of *unchanged* directories on receiver
On Tue, Mar 04, 2008 at 12:21:01PM +0100, Lasse Kliemann wrote:> 'rsync -a' updates the ctime on a directory even if no file in that directory > has changed.Earlier rsyncs always did an extra stat() prior to setting the time, so I've restored that behavior. The attached patch fixes this. ..wayne.. -------------- next part -------------- --- a/generator.c +++ b/generator.c @@ -1949,8 +1949,12 @@ static void touch_up_dirs(struct file_list *flist, int ndx) fname = f_name(file, NULL); if (!(file->mode & S_IWUSR)) do_chmod(fname, file->mode); - if (need_retouch_dir_times) - set_modtime(fname, file->modtime, file->mode); + if (need_retouch_dir_times) { + STRUCT_STAT st; + if (link_stat(fname, &st, 0) == 0 + && cmp_time(st.st_mtime, file->modtime) != 0) + set_modtime(fname, file->modtime, file->mode); + } if (allowed_lull && !(counter % lull_mod)) maybe_send_keepalive(); else if (!(counter & 0xFF))