[nSLUG] How to sync two directory trees
ian at slu.ms
Wed May 27 04:43:05 ADT 2009
On Wed, May 27, 2009 at 03:18:41AM -0300, Mike Spencer wrote:
> 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.
Yes, there is an easy way.
Not as well known as it should be, so spread the word :)
It tries to do things automatically but will prompt you for a decision
if it can't figure out the right thing to do, so it's not *ideal* to
run as a script... however if you need it to run without intervention
I think you can have it either pick a machine that will always
overwrite (if it's not sure) or just ignore those files.
Works similarly to rsync (think it uses the same diff backend), works
over ssh/rsh/whatever, and just like rsync requires unison to be
installed on both sides.
Nice little app.
More information about the nSLUG