2026 Unison sync setup
2026-05-18
Syncthing is great, but I'm going back to Unison. Here's the setup:
First of all, we can run unison -i and cancel it to let it create it's directory and profile.
~/.unison/default.prf
in there, we put our two folders:
root = /home/username/Sync
root = ssh://user@remoteserver//home/username/Sync
# for our use case, include the conflict resolution already
prefer = remoteserver
copyonconflict = true
then, we run unison with Batch mode (non-interactive, just sync automatically+silently) and with automatic conflict resolution from the profile (keeping a copy of conflicting files):
unison -batch
This should sync the folders. attention: if a conflict is detected, the resulting "copy" won't be synced, you need to run it again.
To make it automatic, we can use both filesystem watching and a timer (full scan every 15min):
unison batch -repeat watch+900
While this unison process runs, it should reliably keep our dirs in sync without overwriting in case of conflicts. Next step: create a systemd service that starts this unison process automatically on boot.
first draft:
[Unit]
Description=Unison file synchronization
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/unison -batch -repeat watch+900
Restart=on-failure
RestartSec=30
# Optional: Set nice level to reduce priority
Nice=10
# Optional: Logging
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=default.target
put it in ~/.config/systemd/user (create if needed) and do the usual dance:
systemctl --user daemon-reload
systemctl --user enable --now unison-sync.service