0

Let's say I have a server where I'd like to keep my central Unison repository, and I have two machines with directories Documents and .config on each. I'd like to synchronise Documents and .config to server but only Documents should be synchronised between both client machines. So there should be three directories on the server, Documents, .config_machine1, .config_machine2, where Documents is common between the two client machines, and each .config is specific two each client machine. Is this possible with unison?

Mike Pierce
  • 1,390
  • 1
  • 12
  • 35
ardabro
  • 1,907
  • 16
  • 31

2 Answers2

2

You could run two different Unison profiles on each machine. So on your server, you would have your files look something like

Unison
 \_Common
 |  \_Documents
 \_Machine1
 |  \_.config
 \_Machine2
    \_.config

and then on each machine you would have two different Unison profiles, common.prf to sync the Documents folder, and specific.prf to sync that machine's .config folder.

Mike Pierce
  • 1,390
  • 1
  • 12
  • 35
  • Is it possible and safe to use two profiles using fsmonitor at the same time? Do I need to run two separate program instances? – ardabro Oct 03 '17 at 11:17
  • Yeah I was thinking you'd run two separate instances. Something like `unison -repeat watch common; unison -repeat watch specific`. This should create two different instances of fsmonitor, and that should be fine since there is no overlap between the files they are each monitoring. – Mike Pierce Oct 03 '17 at 14:47
0

This solution feels like a bad idea. At the very least, there must be a cleaner way to execute this idea, but I'm not sure what it is.


You could do a cute thing with symbolic links on your two machines. You could have the files on your server look like this,

Unison
 \_Documents
 \_.config_machine1
 \_.config_machine2

and then on each of your client machines, you could rename the .config folder to .config_machine1 and create a symbolic link named .config to .config_machine1.

cp /path/to/the/dotconfig/folder
mv .config .config_machine1
cd /tmp
ln -sd /full/path/to/.config_machine1 
mv .config_machine1 /path/to/the/dotconfig/folder/.config 

Then you have each machine sync its Documents folder, and its own .config_machine${i} folder. And with the symbolic links, when a program on your machine goes to look for its settings in the .config folder, it'll be linked to .config_machine${i}.

Mike Pierce
  • 1,390
  • 1
  • 12
  • 35