Introduction and Requirements
KeePass 2.x features a powerful, built-in synchronization mechanism.
Changes made in multiple copies of a database file can be merged safely.
After synchronizing two files A and B, both A and B are up-to-date
(i.e. KeePass saves the merged data to both locations when performing
a synchronization).
Requirements.
- If the files to be synchronized are accessible via a protocol that
KeePass supports by default (e.g. files on a local hard disk or a network
share, FTP, HTTP/WebDAV, ..., see the page
Loading/Saving From/To URL for details),
then no plugins/extensions are required.
- If one of the files to be synchronized should be accessed via
SCP, SFTP or FTPS, you need the
IOProtocolExt
plugin, which adds support for these protocols to KeePass.
- If one of the files to be synchronized is stored in an online
storage (like e.g. Amazon's S3, DigitalBucket, ...), you need
an online storage provider
plugin
(e.g.
KeeAnywhere,
KeeCloud or
KeePassSync).
Note that you do not need a plugin
in the other cases above (files on a local hard disk or network share,
FTP, HTTP/WebDAV, SCP, SFTP, FTPS, ...).
Invoking a Synchronization
There are multiple ways how a synchronization can be invoked:
- Manually.
A synchronization can be started manually by navigating to
'File' → 'Synchronize' and clicking 'Synchronize with File'
or 'Synchronize with URL' (depending on whether the file to be synchronized
with is stored on a local drive / network share or on a server accessible via a URL).
If you've previously opened or synchronized with the target file, you can
also simply point on 'Recent Files' (in the 'Synchronize' menu)
and select the file.
Manual synchronization is only possible when the currently opened database
is a local file
(files on a network share are here considered to be local files);
when you've opened a file from a server using a URL,
the 'Synchronize' menu is disabled.
- Command 'Save'.
When invoking the 'Save' command, KeePass checks whether the file on disk/server
has been modified while you were editing it. If it has been modified,
KeePass prompts whether you want to overwrite or synchronize with the file.
Note this applies only to the 'Save' command, not the 'Save As' command.
See the page
Multi-User for details
(section 'KeePass 2.x: Synchronize or Overwrite').
- Triggers.
In more complex situations you can use the synchronization trigger action.
See the page
Triggers for details.
- Scripting.
In order to perform a synchronization without opening KeePass,
the synchronization command of KPScript can be used. See the KPScript
help page
Single Command Operations
for details.
Technical Details
The synchronization algorithm is rather complex and it would take
many pages to describe in detail how it's working.
Developers interested in this can have a look into the KeePass source code.
Here are the most important properties of the synchronization algorithm:
- In order to decide which copy of an object is the latest one,
KeePass mainly uses the last modification time of the object
(which KeePass updates automatically each time the object is changed).
- The synchronization is performed on entry level. This e.g. means that
a combination of user name / password is always consistent
(synchronization on field level will not be implemented, because
combinations could become inconsistent with this).
- In case of parallel updates and collisions, KeePass tries to store
all information in an appropriate place. For example, when you have an
entry E in a database A, make a copy B of A, change E in B, change E in A,
and synchronize A and B, then E in A is treated as current and the changes
made to E in B are stored as a history version of E (see tab 'History' in
the entry dialog), i.e. the changes made in B aren't lost.
Advanced Synchronization Schemes
- Local↔Master Synchronization.
A synchronization scheme that prevents data loss when database files are
overwritten by other applications (e.g. cloud storage service software),
using a trigger.
- Plugins.
There are plugins for more complex synchronization schemes,
for example to synchronize only a subset of the entries.