Synchronize KeePass without conflicts
Synchronize a KeePass database across all your devices with Syncthing instead of Dropbox.
KeePass is an open source tool to store all your passwords. You only need to remember your master password for KeePass and store trillions of individual passwords for each of your accounts. To have all your passwords at hand, you probably want the KeePass database (where all your passwords are stored) on all your devices (phones, laptops, PCs, tablets, etc.). To do so, you can synchronize them. Here is how you can do it, but be aware of the limitations below.
Simple sync (with Dropbox, etc.):
- Store KeePass database file (.kdbx) in your Dropbox share folder, e.g. /Dropbox/keepass.kdbx
- The KeePass file now gets synchronized via Dropbox so that you are able to read/write to that file from your PC, laptop and phone
- But a conflict may occur when you edit the file on your PC and shortly after also on your phone before Dropbox could sync the PC-changes first. As Dropbox can’t merge both changes (KeePass files are encrypted), it will keep both versions of the file. Dropbox tells you about the conflict via the filename. If that happens to you, you now need to merge these files manually: Open both files and copy the changes from the conflict-version to the actual no-conflict-version.
Advanced sync (with Syncthing or Dropbox or …):
The following instruction ensures, that you are always saving the KeePass database to a local file on your PC, which cannot be changed by Android except through the KeePass sync process; you always have a backup in case something goes wrong.
- Work on a local KeePass file on your device (e.g. “D:\MyData\ActiveKeepass.kdbx”)
- Create a copy in your shared folder (e.g. “D:\Dropbox\Shared.kbdx”)
- Create a KeePass Trigger like this:
- In KeePass: Tools > Triggers. Ensure that “Enable trigger system” is checked.
- Add a trigger: “AutomaticSync”. When editing it, check “Enabled” and “Initially on” to ensure that it always runs.
- Under the Events tab, add the following Events, in order, which define the local database:
- Opened database file : Equals, D:\MyData\ActiveKeepass.kdbx
- Application started and ready
- Saved database file : Equals, D:\MyData\ActiveKeepass.kdbx
- Time - Periodic : 3600, No
- Under the Actions tab, add the following Actions, in order, which define the sync path:
- Change trigger on/off state : Off
- Synchronize active database with a file/URL: D:\Dropbox\Shared.kbdx
- Change trigger on/off state : On
- Source: https://github.com/PhilippC/keepass2android/issues/617
- Only KeePass allows triggers (not KeePassXC yet)
- KeePass (without “XC” only runs on Windows natively)
- Syncthing doesn’t work on Apples iOS (Dropbox still runs though)