rsync to sync time without attempting to modify the content
Brice Rebsamen
brice.rebsamen at gmail.com
Tue Apr 2 13:07:43 MDT 2013
Hello
I am setting up a central data repository for my team (several thousands
of files, totaling about 4TB). There are multiple sources that I need to
consolidate: a source may have a fraction of the total number of file,
and there can be conflicts between different sources (that should be
very occasional though). I want to detect those conflicts and manually
merge them. Also, the timestamps of the different copies of the files
can be different as some users have copied the same files to different
locations and changed their mtime (because by default cp does not
preserve timestamps...).
So what I want, is to be able to compare files this way:
if the file does not exist at the destination, then transfer it with
timestamps (rsync -t)
otherwise:
if timestamps and sizes are different:
if md5sums match
if the source time stamp is earlier than the destination
timestamp
update the timestamp of the destination
otherwise report (in a log file or something so that I can come
back to those later)
I tried writing a script to do it, but it turned out to be tedious and I
have the feeling that I am reinventing the wheel here because I spent a
lot of time just parsing the paths on the command line the way rsync
does it. I have the feeling that rsync could do this for me, but I could
not find, in the man page, the option to prevent modifying the content
of the remote file, but allow to update the timestamps. I was thinking
that using rsync in several passes could do the job: a pass in dry run
to compare files, put the files with differences in several lists
according to whether their md5sum matches or based on timestamp
differences, then process those files again with rsync with appropriate
options. But how to get rsync to give me info why files are different?
If that turns out to be too tough, I think I can do it with Unison, it's
just going to take a lot of time to compute all the md5sums and review
all the files for changes...
Hope it makes sense
Brice
More information about the rsync
mailing list