Database latest touch timestamp as trigger's condition to sync
A lightweight and easy-to-use password manager
Brought to you by:
dreichl
Looks like there is no essential condition to sync databases.
The logic sequence should be:
That way we don't need to perform sync with master copy on db opening blindly - time consuming operation, especially over slow network or when db is significant in size.
cheers, Paul
The goal is specifically to avoid downloading entire kdbx for sync when not necessary.
Read-write-rename access is usually directory based (FTP, network shares), so to check that we do not even need to write into kdbx file, that may be some 2 byte temp file in the same dir.
KDBX v4 format has specific header and plain unencrypted hash on some offset. You can't say it's not KDBX database. Also, after each save/sync operation, even the db file size slightly changes. So to ensure the files are the same, only small part of the kdbx file from the appropriate offset should be read and downloaded (even FTP can resume downloads, so it's possible), like a 32 bytes instead of entire kdbx.
Edit 1: Also, when syncronizing, the current default behaviour (re-downloading the entire file after written) might be significally changed thus improving twice the sync speed.
Edit 2: Moreover, I think the remote sync with master db from diff clients is so common usage scenario that I'd seriously consider built-in feature for remote sync as the KDBX database built-in feature, where you just specify the type of remote access protocol, the location/path and master file name, plus access credentials. All that instead of currently let users to mess with triggers, special sync entries and placeholders with UUIDs.
Edit 3: And as I said before, as a dirt and quickest solution, give us even a simplest means to check kdbx file modification timestamp with preset tolerance parameter (in seconds) and compare two files as 'File timestamps near' condition in a trigger. Sure that probably need performing protocol-specific calls and addind a couple of extra credentials fields in the condition.
Last edit: Anonymous 2017-01-28
There is no way to tell if a database has entries that need syncing. The sync process doesn't even check, it just processes each entry and then writes two new files.
Edit 2. KeePass remebers credentials for remote file access so your sync should work just by selecting the file from your recent sync list. There is no need to use triggers for this.
Edir 3. If the database timestamps are different then something may have changed and a sync is required.
cheers, Paul
RE: First paragraph & Edit 3.
Keep in mind that the kdbx file timestamp and file header will change every time the database is saved, regardles of whether user data was actually changed. A consequence of this is that the only situtation where synchronization could be avoided programatically is where neither local version nor the remote (master) version of the kdbx file have been saved since the last sync.
Are you certain that databases are re-download (re-opened) after writing? The target database of the sync pair is saved and closed after a synchronization. Assuming the target database is your remote (master) database, I don't see a reason to download it until the next sync.
I am not certain because I haven't used this feature recently, but I believe the above features are all present and can be accessed from the File>File Synchronize>Synchronize with File URL... menu or using Ctrl+Shift+R
So as I understand your request you need a trigger condition that can compare two files and determine whether they are identical. When combined with the existing trigger condition "Database has unsaved conditions", a trigger system could be devised that would cover the two situations where synchronization is provably unnecessary:
Additionally, you would like to see these conditions built into the logic of the manual synchronization option.
Note: While non-identical KeePass database files may contain identical user data, it is not possible to prove identity without first decrypting the files.
Re #2. No, we don't need compare kdbx files (nor perform sync) when there wasn't a single change made locally. As such the situation will happen on closing local kdbx, we are finished work with it. Thus even if there were changes in remote kdbx, we will catch it next time on opening.
Everything is possible. No decription needed to check the kbdx identity status. Header and its checking hashes aren't encrypted. Read
http://keepass.info/help/kb/kdbx_4.html
Even if plugin for v4 kdbx may be possible, the best thing probably would be an integrated solution, maybe even kdbx v5 may be introduced with that in mind. Plus the sync mechanism should be more robust with clear transactional particals - extra encrypted files or the main kdbx file offsets metadata with just changed entries should be transferred from remote (master) location.
What is needed if the master database was changed (e.g. by another user synchronizing with it)?
True but a file comparison trigger condition shouldn't assume that it will only be used on kdbx files.
I suspect you are making this more complicated that it needs to be. Rather that focus on changing the kdbx file format I suggest you determine what will satisfy your immediate needs given the constraints of the current format.
Last edit: wellread1 2017-01-29
During session nothing. To re-sync, just re-open local kdbx.
Why we have other DB specific conditions like Unsaved changes? That's db-specific conditions, so that trigger condition may be named as "Has remote (master db) changes". But if wanted the normal timestamp and file size equality check may be performed for all files, and additionally, for files with kdbx headers some offset read may be taken. Then name would remain "Remote file different?"
Those are just suggestions for developing. The working logic of internals. Monolitic transfer of entire db over slow network is ridiculous. Now, per default settings, on sync it happens three times: remote location > client to download, client > remote location to to upload new copy, and re-download of this copy back to client to ensure the perfect match.
What most needed for now is a way to set triggers:
a. Not to blindly sync on kdbx opening when there were no changes on remote side;
b. When performing sync, utilizing quick algo implementing hash or some offset piece of remote kdbx file read to check the files are same (with size and timestamp included), intead of currently mandatory first (that should be performed only when remote file timestamp is different [with acceptable tolerance] from the local db replica BEFORE opening, so we know there are possible changes happened on remote side) and practically excessive third downloads mentioned above.
Last edit: Anonymous 2017-01-29
What is it that you would like in as few words as possible?
The simplest and therefore safest sync method is to download, decrypt, sync and save. This makes no assumptions and requires no file access features that may not be available from a remote server.
It is up to you to provide connections to remote files, not for KeePass to manage your slow connections.
cheers, Paul
There are several well-known built-in protocols for remote sync already implemented in KP.
As pointed out in this thread, there is significant overhead in performance and usability regarding remote syncing. That's all my request is about. Using the well known protocol abilities to at least provide a possibility to check file stamp and size of kdbx files and implement comparison condition for triggers accordingly. Ignoration and laziness are bad friends both. Cheers!
Last edit: Anonymous 2017-01-29