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

  1. Create a new directory to use for the Dropbox synchronization, e.g. C:\Documents and Settings\Tom\My Documents\DropboxSync
  2. Note: Do not use the current database location, you must have 2 copies of the database.
  3. Copy (do not move) the KeePass database you want to sync to the new directory.
  4. Open KeePass and navigate to ‘Tools’ → ‘Triggers…'.
  5. Add a trigger.
  6. Call it something meaningful, like “Prevent data loss by Dropbox”.
  7. Navigate to the ‘Events’ tab and add an event.
  8. Select ‘Saved database file’.
  9. 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.
  10. Navigate to the ‘Action’ tab and add a new action.
  11. Select ‘Change trigger on/off state’.
  12. Leave the ‘Trigger name’ field empty.
  13. In the ‘New state’ field change the state to ‘Off’.
  14. Click ‘OK’ to save the action.
  15. Add a new action.
  16. Select ‘Synchronize active database with a file/URL’.
  17. 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
  18. Click ‘OK’ to save the action.
  19. Add a new action.
  20. Select ‘Change trigger on/off state’.
  21. Leave the ‘Trigger name’ field empty.
  22. In the ‘New state’ field change the state to ‘On’.
  23. Click ‘OK’ to save the action.
  24. Save the event.
  25. Set Dropbox to synchronize the database in the Dropbox sync directory.
  26. Perform these steps on all PCs that you will sync with Dropbox.