Search code examples
linuxmergemercurialkeepass

How can I merge keepass database stored in mercurial repository?


I use mercurial to store passwords inside a repository. The problem is that mercurial cannot merge keepass databases. How can I handle this?

I run GNU/Linux by the way.


Solution

  • You are not alone! I had this problem too.

    First of all, you need to install KPScript. It's a little bit tedious process on GNU/Linux, which is described here: http://adunumdatum.org/kepass2-kpscript-installation-on-linux.html. To sum up this article:

    1. Download KPScript.exe.
    2. Find KeePass.exe location by viewing content of /usr/bin/keepass (for me it was /usr/lib/keepass/KeePass.exe).
    3. Copy KPScript.exe to the same folder:

      sudo install -D -m644 KPScript.exe "/usr/lib/keepass/KPScript.exe"
      echo -e '#!/bin/sh\n/usr/bin/mono --runtime=v4.0 /usr/lib/keepass/KPScript.exe "$@"' > /tmp/kpscript
      sudo install -D -m755 /tmp/kpscript "/usr/bin/kpscript"
      

    After installing kpscript you can use it to sync your databases (see http://keepass.info/help/v2_dev/scr_sc_index.html for more details).

    Finally you need to add those lines to the .hgrc:

    [merge-patterns]
    **.kdbx = keepass
    
    [merge-tools]
    keepass.executable = /usr/bin/kpscript
    keepass.args = -c:Sync -keyprompt $local -File:$other
    

    Now you can merge your keepass databases. Congratulations!