# Two-Way ZFS send+recv instead of rsync?



## vanessa (Nov 11, 2013)

I know how to send ZFS snapshots to a remote machine, but I would also like to use the latest changes sent to a server to update the filesystem on another client. 

Suppose someone working on client C creates a new file. After a while a snapshot is taken and sent to a server S. The same person then logs on to his laptop L. Now, is there a scenario where L fetches the latest snapshot from S and updates its local filesystem? 

How could a two-way synchronisation be achieved using only `zfs send` and `zfs recv`?


----------



## mav@ (Nov 11, 2013)

It may work if all updates for each time frame will be done at only one place, snapshotted there and replicated to other hosts. I.e. L should not have any local changes after its last sync with S when a person logs in there. Otherwise you'll get a split-brain condition and have to revert one of sides to the last common snapshot to continue updates.


----------



## vanessa (Nov 11, 2013)

So basically, it would be better to stick with rsync, wouldn't it?


----------



## mav@ (Nov 12, 2013)

The problem of split brain (if you modified data on two systems same time) has no obvious solution. Depending on specific settings rsync may try to solve it in one or another way. I guess it may be more flexible then ZFS at doing this, but no solution probably will be absolutely correct there. But if you manage to avoid split brain case in some way ZFS replication should be more efficient, I think.


----------



## vanessa (Nov 12, 2013)

OK, how could I avoid split-brain? With rsync there is a time stamp for each file, so it is easy to check which one is newer or older. Is there a similar option for ZFS?


----------



## Savagedlight (Nov 12, 2013)

vanessa said:
			
		

> OK, how could I avoid split-brain? With rsync there is a time stamp for each file, so it is easy to check which one is newer or older. Is there a similar option for ZFS?



There's no such alternative for ZFS that I know of. Do keep in mind that the timestamp syncing doesn't work perfectly either. If the same file is edited on two different locations, only the file which was altered last would be kept; losing the changes in the one which was edited first.


----------



## vanessa (Nov 12, 2013)

This is pity, thank you though!


----------



## jrm@ (Nov 12, 2013)

Perhasp net/unison-nox11 might be useful for what you're trying to do.


----------



## vanessa (Nov 12, 2013)

There are several good tools or scripts out there but I wanted to fully employ ZFS if possible as both the server and all clients run on ZFS.


----------

