How do you merge two conflicting files with Unison

394 Views Asked by At

I am having two nfs servers across which I am trying to sync files. I have the unison profile sync.prf this way.

root = /home/ubuntu/nfs                                # shared directory on server1
root = ssh://[email protected]//home/ubuntu/nfs       # shared directory on server2
ignore = Name .git
merge = Name /home/ubuntu/nfs/*txt                     

There is a hello.txt file in server1 as well as in server2. I am trying to merge the content from files across the servers.

While I run the profile using unison sync.prf, I am getting the failed synchronization. The error is as follows:

ubuntu@ubuntu-shivam:~$ unison sync.prf                              
Contacting server...
Connected [//sshtest-vm-intern//home/ubuntu/nfs -> //ubuntu-shivam//home/ubuntu/nfs]
Looking for changes
  Waiting for changes from server
Reconciling changes

local          sshtest-v...
changed  <=M=>            hello.txt  [f] m

Proceed with propagating updates? [] y
Propagating updates


UNISON 2.48.4 started propagating changes at 18:04:36.00 on 05 Jan 2023
100%  00:00 ETAFailed [hello.txt]: 'merge' preference not set for hello.txt
UNISON 2.48.4 finished propagating changes at 18:04:36.01 on 05 Jan 2023


Saving synchronizer state
Synchronization incomplete at 18:04:36  (0 items transferred, 0 skipped, 1 failed)
  failed: hello.txt

I have tried implementing the merge option in following some ways, but not getting the successful synchronization.

Path /home/ubuntu/nfs = update
*.txt update
*.txt = update
Name /home/ubuntu/nfs/*.txt
/home/ubuntu/nfs = update
Name /home/ubuntu/nfs/*.txt = merge=update
Path /home/ubuntu/nfs = merge=update
merge = diff3 -m /home/ubuntu/nfs/*.txt OLD /home/ubuntu/nfs/*txt > NEW

Kindly someone help me with the issue.

1

There are 1 best solutions below

1
On

Your syntax for the merge option isn't correct. It should look something like

merge = Name *txt -> diff3 -m CURRENT1 CURRENTARCH CURRENT2 > NEW

See the see the Merging Conflicting Versions section of the Unison Manual for details and examples.