[nSLUG] How to sync two directory trees
mspencer at tallships.ca
Wed May 27 03:18:41 ADT 2009
Is there an easy way to sync or update two nearly identical directory
I have two machines.
+ One, call it HD1, holds the canonical set of files in a hierarchy
of directories totaling nearly two gig.
+ The other, HD2, holds the same set of files.
But some new files have been added to HD1 and some files on HD1 have
changed. I would like to say something like:
For each file, foo, in or under /home/base/<path-to-foo> (on HD1)
if !exist /mnt/HD2/home/base/<path-to-foo>
copy /home/base/<path-to-foo> to corresponding place on HDx
if different /home/base/<path-to-foo> \
delete the version on HD2 and copy over the version from HD1.
where "different" might be as simple as different sizes or dates.
Either of the HDs can be mounted on the other machine's filesystem as
/mnt/HDx via local router. This not a task that needs to be done on
the fly and ongoingly to *keep* the two dir trees in sync.
I've long ago scripted this to update a single flat directory with
lots of error checks etc. But it gets messy and error-prone for a
fairly extensive directory tree.
Is there a straightforward tool to do this? Or is it optimal to just
delete the out-of-date directory tree and copy the whole 2 gig anew?
Bumbling about as usual,
Michael Spencer Nova Scotia, Canada .~.
mspencer at tallships.ca /( )\
More information about the nSLUG