# [Resolved, sort of] (near) real-time replication over a wan

## digix

I searched several times and didn't find any posts quite like the setup I'm trying to achieve here...

I'm configuring 4 servers to be installed in our offices world-wide. The end goal is to have certain directories replicated among all the servers for availability via the local samba shares in each office; (near) real-time is ideal.

I've looked at several options as far as commercial packages, but none seem to be exactly what we need or they have some major drawback to them.

Can anyone suggest another solution to this? Is this even feasible at this time?

Thanks in advance,

-Digix

----------

## digix

I seem to have found my solution in Unison

----------

## Vieri

I tried Unison too but am stuck with file permissions.

The files are propagated with the user and group of the unison server process.

So even if the same unix users exist on all remote servers to which you are unison'ing, the files will lose their ownerships.

I don't know what other practical solutions I can try.

Maybe if it were the same filesystem but over a network...

Supposing it were a RAID-1 but with the "second" disk/partition on a remote server. One could use:

DR:BD (http://gentoo-wiki.com/HOWTO_Heartbeat_and_DRBD  -  http://www.drbd.org/)

or

iSCSI (http://gentoo-wiki.com/HOWTO_iscsi)

or

ATAoE

But I suppose that it would be very slow over a wan link.

And if the two servers can't see each other at times (which is often the case over wan links) and there are local writes both on server A and B, then disk data would be inconsistent and I don't know how the RAID would re-sync.

Never tried this.

Has anyone?

----------

## digix

 *Vieri wrote:*   

> I tried Unison too but am stuck with file permissions.
> 
> The files are propagated with the user and group of the unison server process.

 

I was able to fix this through the unison profile for the user that runs the process.

```
~/.unison/default.prf

owner = true

group = true

perms = -1
```

With those settings in your unison profile, the files will preserve the unix owner/group permissions, but any extended acls will, however, still be lost.

----------

## Vieri

 *digix wrote:*   

> With those settings in your unison profile, the files will preserve the unix owner/group permissions, but any extended acls will, however, still be lost.

 

Thanks, I stumbled on that too. Will try it. I'm wondering if it will also preserve Windows shared files (my box has winbind and active directory auth and wbinfo -u does list all windows users). Crossing my fingers...

----------

## Vieri

 *digix wrote:*   

> but any extended acls will, however, still be lost.

 

Any workaround for this?

I need to preserve ACLs...

I think rsync can preserve them but can rsync do two-way syncs? (I don't think so)

----------

## Vieri

 *digix wrote:*   

> but any extended acls will, however, still be lost.

 

I think I found a hack for this two-way synchronization thing. The idea is to use Unison's two-way algo and then take advantage of rsync's ACL support. The following script seems to work for me although I just started testing it:

```
#!/bin/bash

unison -batch -times -owner -group -perms -1 /path/dir ssh://remote//path/dir

rsync -e ssh -vaur --acls --xattrs --partial --compress /path/dir/ remote:/path/dir/

rsync -e ssh -vaur --acls --xattrs --partial --compress remote:/path/dir/ /path/dir/

```

I would appreciate it if someone could test this and/or let me know if there's a better way.

----------

