One problem and an overcomplicated solution (in pursuit of KNOWLEDGE)

I keep my study notes in Obsidian on my desktop and wanted them on my laptop and phone, with a local copy I can use offline at the library and sync when I get home. I decided to set it up as rootless Podman containers with the fewest mounts I could manage, and nothing reachable from the internet.

How it’s set up

Each device keeps its own vault as plain files. The Self-hosted LiveSync plugin copies changes between them through a CouchDB database on my desktop. Notes are encrypted on the device before they leave it, so the server only stores encrypted note content. The server never sees the vault folder either.

CouchDB and Caddy run as two containers in one Podman pod. Containers in a pod share a network namespace, so Caddy reaches CouchDB over loopback, and the only port published is Caddy’s HTTPS port on my home network. Nothing is forwarded on the router and there’s no public domain.

Caddy’s tls internal gives the server HTTPS signed by its own small certificate authority, which means I don’t need a domain or an outside certificate service for a LAN address. Each device has to trust that authority’s public certificate, and I check its fingerprint before installing it anywhere.

The database has two accounts. I only use the admin account for the first-time setup. Day to day, the devices use a second account that can read and write the notes database but can’t change any server settings or permissions.

The container images are pinned by digest, so a restart never quietly pulls a new version, and I update CouchDB and Caddy manually when I’m ready to.

What went wrong

Most of the time I spent setting this up was troubleshooting these three problems.

  • Permissions. The first-device setup reset the database permissions, which locked out the day-to-day account. I changed the setup script to keep existing permissions and save a copy whenever it changes them.

  • Notes that never arrived. Some new notes didn’t reach my phone even though every server check passed. The desktop and the server had ended up with different keys for file IDs, so the desktop refused to replicate. I backed up both sides, rebuilt the server copy from the desktop, and reset the vault on my phone to download the base version.

  • The runtime. At one point I moved the server into a Distrobox so I could start and stop it from a desktop app. Then I noticed that Distrobox gives the container full access to your home folder, which felt like a whole can of security worms for a network service.

    So I moved it back to a plain pod that mounts only its own data folder, and kept the Distrobox version stopped in case I needed to roll back. I deleted it once I’d confirmed everything worked in the new pod.

Backups

Sync isn’t a backup. If I delete a note, the deletion syncs to every device, so I have three safety layers. One command stops the pod for a moment and archives the database, settings and certificates. Another one archives the vault itself once a week and checks every file against a checksum. The vault is also in my daily encrypted backups along with my projects.

To make sure the snapshots actually restore, I wrote a script that unpacks one into a separate test pod that only the desktop itself can reach. It runs the same checks as the live server, prints how many records came back, and then removes the test pod.

Trade-offs

The server only works while my desktop is on, so I edit offline when I’m out and let changes catch up when I’m home, which suits how I study.

Self-hosting isn’t inherently more private. Obsidian’s paid Sync also encrypts notes end to end.*

This is free, and I get control over where my data is stored and who can access the server. In exchange I’m the one keeping it updated and backed up, and if anything breaks, I’m the one who needs to fix it, but that upkeep is a big reason as to why I built it. It’s practice on a system I use every day.

Sources

* Wellll it’s complicated: end-to-end encryption is the default for new remote vaults, but Obsidian lists some metadata that isn’t encrypted end to end, such as upload times and which device made a change (Limitations).