Prefer -u not to change newer files.

Matt McCutchen matt at mattmccutchen.net
Sun Jan 27 11:33:13 GMT 2008


On Sun, 2008-01-27 at 12:20 +0100, Donald Axel wrote:
> > 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 uffe.ruc.dk but
> for some reasone I need to do things fast and edit the script on
> rolf.ruc.dk 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:-)

That's nothing compared to some of the messages on this list.  :)

Yes, you should probably be using something better suited for the
purpose than rsync.  You could use a two-way synchronization tool such
as Unison ( http://www.cis.upenn.edu/~bcpierce/unison/ ), which has a
nice GUI, preserves file attributes, and supports basic textual merging
of changes to the same file on both sides.  Or you could use full-blown
version control, which will give you more help with merges (and keep
history in case you mess up) but not as much with file attributes.  If
you explain what the issue with SVN is, I might be able to suggest a
different version control system or setup that would work.

Matt



More information about the rsync mailing list