(This is a bit old, but I’ve stumbled into here during a different search, and happened to spend a decent bit of time checking this problem out in the past).
Cloud sync isn’t ideal, though for reasons (my personal server runs Nginx, and that’s not great with WebDAV) that’s what I’m using right now - specifically with Syncthing. I’ll probably look into getting WebDAV running again at some point, because I’m lazy.
TL;DR: if you can, use a WebDAV share that supports the file locking extensions. Put it in your fstab, but as noauto. Then add a user service a bit like this:
[Unit]
Description=Mount WebDAV Service
After=network-online.target
Wants=network-online.target
PartOf=graphical-session.target
[Service]
Type=oneshot
ExecStart=bash -c 'for i in {1..15}; do if ping -c 1 <davserver>; then mount /home/<user>/Mounts/<something>; break; else sleep 1; fi; done'
ExecStop=umount /home/<user>/Mounts/<something>
RemainAfterExit=true
[Install]
WantedBy=graphical-session-pre.target
(You might want a different Target
and PartOf
- this is to make the mount come up/down with the graphical session, because that’s what I want.
But you want something that supports locks - so that two clients accessing and writing to the database at the same time are less likely to step on each other’s fingers. There’s a degree to which Keepass implementations try to avoid this, but it’s limited - for example, at least on iOS you don’t have good guarantees of the latency between change on system A, and your cloud app updating it on your phone.
Some apps, e.g. KeePassium (an iOS client) and KeePass 2 (the OG and arguably the “reference” implementation) support WebDAV directly, including locking extensions. This works fine for KeepassXC as well, because you can mount a WebDAV share directly on pretty much any OS - and treat it just like a filesystem in a way that’s more meaningful than for most cloud sync solutions.
Rant
I wish KeepassXC used, like, Hashicorp Vault] or similar as a backend. KeePass was great when it started, and a single file does seem simple to handle, but concurrency messes this up really badly, and I’ve had that become a problem in practice quite a bit - like it’s not at all uncommon for me to add or change a password on one machine, and use it on another immediately. Especially when the other is a phone. Things get extra messy if I try to also change it on the other machine. The delays are just enough to make it pretty bad with any cloud sync.