Keepass Syncing the Database
Published: Estimated reading time: ~2 minutes
Storing the Keepass database in your NextCloud, Google Drive, OneDrive, or other storage is convenient if ou need to have access to the database from multiple machines both in and out of your home network.
There is a problem with this setup though.
Both NextCloud sync and Keepass will be trying to sync different verions of the database at some point.
Let’s say you have two computers, both pointing to the Keepass database stored on a synced cloud storage provider.
Dropbox will synchronize files between computers, but it can’t determine what changes KeePass has made, only that the database has changed. To ensure that KeePass changes are not lost by Dropbox, you need to use a second copy of the database that is just for the Dropbox synchronization. Then use a KeePass trigger to move changes between KeePass and Dropbox.
https://keepass.info/help/kb/trigger_examples.html#dbsync
- Create a new directory to use for the Dropbox synchronization, e.g. C:\Documents and Settings\Tom\My Documents\DropboxSync
- Note: Do not use the current database location, you must have 2 copies of the database.
- Copy (do not move) the KeePass database you want to sync to the new directory.
- Open KeePass and navigate to ‘Tools’ → ‘Triggers…'.
- Add a trigger.
- Call it something meaningful, like “Prevent data loss by Dropbox”.
- Navigate to the ‘Events’ tab and add an event.
- Select ‘Saved database file’.
- If you only want to sync a certain database, set the ‘File/URL - Comparison’ to ‘Equals’ and the ‘File/URL - Filter’ field to the required database file path. Otherwise don’t change the fields.
- Navigate to the ‘Action’ tab and add a new action.
- Select ‘Change trigger on/off state’.
- Leave the ‘Trigger name’ field empty.
- In the ‘New state’ field change the state to ‘Off’.
- Click ‘OK’ to save the action.
- Add a new action.
- Select ‘Synchronize active database with a file/URL’.
- Enter the full path and name of your copy of the KeePass database in the ‘File/URL’ field, e.g. C:\Documents and Settings\MyName\My Documents\DropboxSync\MyDatabase.kdbx
- Click ‘OK’ to save the action.
- Add a new action.
- Select ‘Change trigger on/off state’.
- Leave the ‘Trigger name’ field empty.
- In the ‘New state’ field change the state to ‘On’.
- Click ‘OK’ to save the action.
- Save the event.
- Set Dropbox to synchronize the database in the Dropbox sync directory.
- Perform these steps on all PCs that you will sync with Dropbox.