3

In Ubuntu 14.04 systems I would like to store the same contents of a directory in two different hosts (1). This is to let the same person work on different workstations on the same LAN, having the same files available at any time, regardless of the workstation he decided to work with: they can be text files, configuration files, but also pdf and so on. (2)

Both the workstations can use sshfs, but not NFS. I need real-time (so no rsync), bi-directional (so no lsyncd) syncronization between the two directories.

Does exist a tool, or filesystem, which is able to perform this?


(1) This is also to make a backup: if one workstation is down, the other already has all the files. I don't need neither symbolic links, nor mount --bind, because the contents should be stored in different devices.

(2) This is the main scenario. A unique USB key can be used, but often the number of files and their total dimensions are huge, so they would require a hard disk.

  • 2
    Is there any reason that dirA or dirB could not simply be a symbolic link to its counterpart? – DopeGhoti Feb 22 '17 at 17:37
  • @DopeGhoti Yes: the fundamental fact that they should be in different devices, such as different disks or (as in the second question) different hosts. – BowPark Feb 22 '17 at 17:39
  • 2
    Then why don't you just mount dirA on server B? Or, if on the same machine, mount --bind it. Would that be acceptable? – terdon Feb 22 '17 at 17:45
  • 1
    @BowPark I don't really understand what you mean. Please edit your question and give us more details. Specifically, clarify what your final objective is and how links and mounting wouldn't work. Oh, and please specify your OS since that's quite relevant. EDIT: No, I see what you mean, OK. But still, pelase edit and clarify regardless. – terdon Feb 22 '17 at 18:12
  • 1
    @terdon I had previously specified the OS, Ubuntu 14.04. But now I tried to edit the question being more clear. Now I hope it is also clear why symlinks and --bind would not fit. – BowPark Feb 22 '17 at 18:20
3

Real-time replication across machines is possible, but it's hard to do this with good performance. Each participating machine needs to synchronize with the other machines to access a file, to avoid a conflict (two machines modifying the same file at the same time in incompatible ways).

There are a few filesystems that do this. ChironFS is one (open source); as far as I know, it's reasonably mature, but it's unmaintained. FlexRAID also has such a filesystem; it's maintained, but not free (not very expensive though).

Do you really need real-time bidirectional synchronization? A simpler system with either policies to avoid conflicts or manual conflict resolution, such as offered by version control systems, is likely to have better performance and stability.

  • I tried to update, simplify and clarify my question. Maybe a version control system could be suitable, but in that case it would need a unique place to store data, isn't it? – BowPark Feb 23 '17 at 11:26
  • @BowPark not really. Git, for example, stores a copy of the repository's state at both ends. And, if you upload to github, remotely as well. If either directory is deleted, the contents can be retrieved from the the other. – terdon Feb 23 '17 at 11:31
  • @terdon and the disadvantage is only that it is not real time? – BowPark Feb 23 '17 at 11:34
  • @BowPark afaik, yes. Although you can make it pretty close if you use something like inotify to monitor the directory for changes and push any changes as soon as they are made. You might have issues with conflict resolution, but that will depend on your usage. It would probably be worth asking a new question about how to do this using git, actually. I don't have a lot of experience with it, so I may well be missing something obvious. – terdon Feb 23 '17 at 11:35
  • @terdon Starting from two exactly equal directories, maybe conflicts are not a big issue, because only one workstation is used at a time. I agree with opening a new question if needed. Thank you! – BowPark Feb 23 '17 at 11:40
0

With out knowing why you want to mirror a directory real time across, I'm not fully sure what to suggest.

Is it for backups or recovery? If so, maybe setup a mirror across the devices?

Is it to have the directory in another location? Maybe try using a loopback mount? Or use an automount? You could even share one directory via NFS, and mount it to a different location?

  • I tried to update my question in order to simplify and clarify, hoping that I added the details you needed. – BowPark Feb 23 '17 at 11:29
  • Can you put the files on a server and share them out to the workstations? Ideally the server would be using some type of RAID (hw or sw), as well as being backed up. If not, it's slight overkill, but you could use a distributed filesystem. Check out OpenAFS. – sleepyweasel Feb 23 '17 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.