davlog: a WebDAV server where every save is a git commit

Why

I keep my notes as plain markdown files and sync them between a few devices. For a while I used Obsidian with a WebDAV sync plugin, and more recently I’ve been using HelixNotes, which can sync over WebDAV too.

HelixNotes has a pretty good sync algorithm and I haven’t lost anything with it. But sync is the one place my notes can disappear: two devices disagree about who changed what, a sync dies halfway, a file gets overwritten. I’d rather know I’m covered if there’s a bug, in the app or anywhere else.

Git is great for that with plain files, but most WebDAV servers keep no history. The usual workaround is a script that watches a folder and commits it. That tends to commit half-written files and say nothing when a push fails. I didn’t find anything that did what I wanted, so I wrote davlog.

What it does

davlog is a WebDAV server that stores its files in a git repository. Every upload, delete and move becomes a commit:

$ git log --oneline
3f2a9c1 davlog: update projects/pizza-night.md
b81d0e4 davlog: move drafts/idea.md -> projects/idea.md
9c07e55 davlog: delete scratch/old-list.md

It’s just a normal git repository, so you can look through it and work on it with the usual git tools. If a sync goes bad, I can undo it with git revert.

davlog doesn’t care which app is syncing, though so far I’ve only tried HelixNotes and rclone.

Along the way it:

  • pushes to a backup remote on a timer, if you want one (mine goes to my NAS over SSH twice a day)
  • emails you when something goes wrong, like a failed push or a full disk
  • never writes half-finished uploads into your history
  • backs off while you’re fixing something by hand with git

Speed and size

It’s light and fast. These are from my testing with 5,000 notes in the repo:

  • Memory when idle: about 14 MB
  • Reading a file: about 0.15 ms
  • Saving a file, including the git commit: about 4 ms

With 8 clients saving at the same time, a save takes about 15 ms each, and it handled around 490 commits a second.

That was on a 16-core desktop, so a small server will be slower, but I haven’t noticed any delay in real use.

Running it

davlog is packaged as a Docker image, so there’s nothing to build or install on the host. The README has a short compose file to get started, and another that puts it behind Caddy for HTTPS.

It’s at 1.0.0-RC5 and I’m the only person running it so far. If you try it and something breaks, open an issue.