2

I've been using unison as my file synchronizer of choice and life has been great.

Essentially I could modify any files on any side at any time without ever worrying who's master and slave, etc. It's bidirectional.

However with four roots failing over to each other when each's primary partner cannot be reached, I'm starting to push the limits of this tool. Conflicts arise that halt automatic syncing for the files involved. Aspects of my business logic are distributed across the different hosts, which modify sometimes the same files when run.

The merge option in the configuration file comes into play. It lets you specify different merge commands for different file types.

For example for log files only I like to interpolate their lines with:

merge = Name *.log -> diff3 -m CURRENT1 CURRENTARCH CURRENT2  > NEW   || echo "differences detected"

Question: for *.last files only, what merge command would always favor the older copy?

For *.rb *.sh and other source files, I'm not looking to merge but always pick the newer version in case of conflicts. I can do that by default with the prefer = newer global option though.

For *.png files I typically prefer to keep the smaller(optimized) size.

Community
  • 1
  • 1
Marcos
  • 4,796
  • 5
  • 40
  • 64

1 Answers1

1

Regarding the .rb and .sh files, you could use the preferpartial = Name *.rb -> newer and the same for .ssh files. For .last files, you can use older instead.

Regarding .png files, you could write your own merge command that checks the size of both files. I would then set merge = Name *.png -> mycmp CURRENT1 CURRENT2 NEW, and have the mycmp command takes three file path, compare the size of the first two, and copy it to the third path.

brab
  • 386
  • 2
  • 5