Prefer -u not to change newer files.

Donald Axel donax at
Sun Jan 27 11:20:56 GMT 2008

On Sun, 27 Jan 2008 05:58:19 -0500
Matt McCutchen <matt at> wrote:

> On Sun, 2008-01-27 at 02:22 +0100, Donald Axel wrote:
> >     Quoting man page:
> > 
> >               In  the  currently implementation, a difference of file format is
> >               always considered to be important enough for an update, no matter
> >               what date is on the objects.  In other words, if the source has a
> >               directory or a symlink where the  destination  has  a  file,  the
> >               transfer  would  occur  regardless of the timestamps.  This might
> >               change in the future (feel free to comment on this on the mailing
> >               list if you have an opinion).
> > 
> >    Comment: -u should preferably mean "update" only if target is older.
> > 
> > 
> >    Actually I found out by experimenting that rsync may overwrite
> > anything different at the target. 
> > 
> >    Using the -u option as "only if newer" would be analogous with zip,
> > unzip and cp and probably many other program.
> OK...could you give us a concrete example in which it is helpful to have
> the straight "only if newer" behavior instead of the current one?

Yes, I can: If this answer is too long, please excuse me - I am
relaxing when I write:-)

I am sometimes (every year or so:) using e.g. pdcrypt or a script for
making Xen-guests for some specific course, and I have
modified/improved the script. However, there are more than two machines
on which I run the script, and it all works nicely until at some
point where I need to correct some typo in some trap or error
handler. Normally I distribute the script from system but
for some reasone I need to do things fast and edit the script on in stead. Stupid, yes! but the outcome is a working setup
and a happy family when I come home not too late.

I now have (at least) two variants. I want to remerge the source, and
as usual I do not want to trust my memory 100% when there have been 117
interruptions and questions while I was working; so I copy source to a
workstation (e.g. dax:/sysadm/master, dax:/sysadm/uffe, dax:/sysadm/rolf). 

In order to get the corrected version into the "mastersource" I use
cp -upRiv /sysadm/{rolf and so on} /sysadm/master

But instead, maybe I could use an -u option for rsync to accomplish the same:

   cd /sysadm/master
   rsync -av -u uffe:/source/ dax:/sysadm/master
   rsync -av -u rolf:/source/ dax:/sysadm/master
   rsync -av -u some-third-machine:/source/ dax:/sysadm/master

   ... etc.

Maybe there are other ways to accomplish the same, SVN or CVS maybe?
And maybe that would be a better solution in the long run, but I am not
sure at the moment that SVN is an option.

   Thanks for reading, I hope it was not too long after all:-)

   Regards/Donald Axel

-- -- Donald Axel --

More information about the rsync mailing list