Syncing app configurations across machines with unisync
Published: 2022-11-25 01:09:56

---
title: Syncing app configurations across machines with unisync
published: true
date: 2022-11-19 00:00:00 UTC
tags: 
canonical_url: https://david.coffee/unisync-release/
---

![unisync](https://david.coffee/assets/2022-11-unisync/unisync.jpg)

**tl;dr** : [unisync](https://github.com/dvcrn/unisync) is a little tool I wrote that diffs and syncs your application settings across Macs, powered by unison

Config management across machines is kind of a PITA. Some apps luckily natively support syncing settings, but most don’t.

There are some solutions like the excellent [Mackup](https://github.com/lra/mackup) that try to fix this issue by moving all config files into a shared folder (like Dropbox), then creating symlinks from the application settings folders (eg `~/Library/Preferences/xxxx.plist`) into that Dropbox folder.

I used mackup for a while (even with my own [config files](https://github.com/dvcrn/dotfiles/tree/master/mackup)), but eventually got frustrated when symlinks randomly broke, for example, because the app decided it wanted to write the full file fresh to disk, effectively overwriting the symlink. Then some other apps detect symlinks and refuse to read them.

I tried to mitigate that by [creating a PR to mackup](https://github.com/lra/mackup/pull/1779) that adds support for hardlinks, but tl;dr: hardlinks in APFS are not really hardlinks, and this is even more fragile with cloud storage than using symlinks.

## Unison is great

[unison](https://github.com/bcpierce00/unison) is one of these really old tools that’s been around and developed forever. It’s a

> \*“Unison is a file-synchronization tool for POSIX-compliant systems (e.g. _BSD and GNU/Linux), macOS and Windows, with the caveat that the platform must be supported by OCaml”_

basically, it syncs files, kind of like a bi-directional rsync: Where rsync syncs one way (and alternatively deletes files), unison goes both ways and finds files that changed, got added or deleted across multiple directory nodes.

Bi-directional sync makes it great for those pesky config dirs that could change on one host without us noticing. By diffing the directories against, say, a directory in Dropbox, unison can determine what actually changes, and copies the files accordingly.

If a file is updated on Host B and is then synced through Dropbox to Host A, unison on Host A would see that the file in Dropbox is now newer than on the local one, and overwrite it with the version from Dropbox.

unison can even sync _across_ machines directly!

## Mackup + Unison = Unisync

That brings us to [unisync](https://github.com/dvcrn/unisync). Unisync is using the Mackup idea of having a library of app configurations that state where config files are, but instead of using symlinks, it calls into `unison` to do the actual copying of files. So in theory, if files changed on one machine and then get synced to other machines, those files would get marked as changed / new, and get copied over the existing local file.

![Unisync screenshot](https://david.coffee/assets/2022-11-unisync/unisync-screenshot.png)

Because unisync is using unison under the hood, we can do more fancy things like providing a tree with files we want to handle, but add regex or naming patterns to ignore rules:

```
name: Raycast
friendlyName: raycast
files:
  - basePath: ~/Library/Preferences/
    includedFiles:
      - com.raycast.macos.plist
    ignoredFiles:
      - Name somethingToIgnore.plist

```

Unisync also supports the [entire Mackup app library](https://github.com/dvcrn/unisync/tree/main/apps/mackup) for syncing to get you started, and comes with LaunchAgents that make it run automatically in the background.

Check it out on GitHub and let me know if this tool is useful for you: [https://github.com/dvcrn/unisync](https://github.com/dvcrn/unisync)