I was disappointed when I found out that -t ("preserve times") only
applies to the destination. In other words, when you rsync a file, its
atime gets updated. Yes, rsync does access the file to read it, but if
I'm doing periodic archival rsyncs, I want to preserve the last "real"
access, not the one by the last backup process.
I'm including a patch against version 2.4.4 sender.c to preserve the
access time on source files. It's a bit crude (in that it preserves the
atimes whether you specified -t or not, doesn't check to see if the
utimes() call succeeded, and I've only tested it with FreeBSD 3.x)
but it works for me. Consider this a proof of concept if you like.
Perhaps this could be turned on with a different command line option,
separate from -t. I'd definitely want it turned on as one of the functions
of -a.
--- sender.c-orig Wed Aug 16 10:16:54 2000
+++ sender.c Wed Aug 16 10:37:50 2000
@@ -93,6 +93,7 @@
int phase = 0;
extern struct stats stats;
struct stats initial_stats;
+ struct timeval preserve_time[2];
if (verbose > 2)
rprintf(FINFO,"send_files starting\n");
@@ -160,6 +161,18 @@
return;
}
+ if (stat(fname,&st) == -1) {
+ io_error = 1;
+ rprintf(FERROR,"send_files failed to stat %s: %s\n",
+ fname,strerror(errno));
+ free_sums(s);
+ continue;
+ }
+ preserve_time[0].tv_sec = st.st_atime;
+ preserve_time[0].tv_usec = 0;
+ preserve_time[1].tv_sec = st.st_mtime;
+ preserve_time[1].tv_usec = 0;
+
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1) {
io_error = 1;
@@ -209,6 +222,7 @@
if (buf) unmap_file(buf);
close(fd);
+ utimes(fname,preserve_time);
free_sums(s);