Menu

#2317 During synchronization, if the connection is interrupted, the remote database gets corrupted

KeePass_2.x
closed
nobody
5
2024-04-19
2024-04-17
Ely
No

Hello.

I hope this haven't been reported. Been looking for about an hour and couldn't find anything in the forums nor in the tickets.

Many times now, in the middle of a Sync process (using ftp), the connection to the remote database has been interrupted. Every time that this happens, the remote database gets corrupted and I haven't been able to fix it

I can think of two ways to help in this matter:
1. To add an option to backup remote database before sync. I think it could be overwritten every time. Couldn’t do this with a trigger, since there is no placeholder for the remote database name (I have more than one). I also couldn’t find a plugin.
2. Find a way to fix the remote "corrupted" database whenever the Sync process gets interrupted. I don’t even know if it’s possible.

Since I've lost important information, I think this is a bug. That’s why I've opened this bug report.

Any help would be really appreciated.
Thank you in advance.

Ely.

Discussion

  • Paul

    Paul - 2024-04-18

    KeePass asks the server to write a new file, checks that it has been written, then deletes the old file and renames the new file. It is up to your FTP server to honour these requests, but there isn't much KeePass can do if it doesn't.

    Did you receive an error message? If not then it is your FTP server.
    Have you tried turning off "use file transactions" under Tools > Options > Advanced, File Input/Output Connections?
    Have you tried the IOProtocolExt plug-in? It replaces the .NET FTP mechanism with WinSCP.

    If you are performing a sync, how did you lose information? The local file will still be OK. Did you mean a Save?

    You could use a trigger to perform a local backup.
    What does the {DB_NAME} placeholder return? Use a "show message box" action to view it.

    cheers, Paul

     
  • Ely

    Ely - 2024-04-18

    Yes, the problem is the ftp server in the remote device. What I can see is this, when happens that before the synchronization ends, and the remote ftp/net connection stops, the main machine (where KeePass is running) hangs. After a timeout, everything works ok in the main equipment. But when the connection get's on again and I try again the sync, then I receive an error saying the remote database is corrupted. That's why I loose information. I lookded for a backup stored in the main equipment and in the remote equipment without success... where the remote database backup get's stored, if it does?

    The only way to get the remote database working again, is to copy the one stored in the main equipment, loosing permanently the records added or modified directly in the remote equipment's database.

    Nothing is different if the ftp/net connection get's reestablished before the timeout... simply breaks anyway, after the timeout.

    What does the "use file transactions for writing databases" do? Why could help if I enable the option to prevent them?

    The IOProtocolExt sounds promising. My first tests show it retries instead of dropping the process. But I need to test it better.

    Thank you so much for your prompt response.

     
  • Dominik Reichl

    Dominik Reichl - 2024-04-18
    • status: open --> closed
     
  • Dominik Reichl

    Dominik Reichl - 2024-04-18

    When saving/synchronizing fails, the error message that KeePass displays already mentions that the target file might be corrupted. I don't see how the saving/synchronization behavior or the error reporting could be improved.

    KeePass does not use file transactions for FTP URLs, because there is a bug in .NET (Connect 621450) that causes file renames to fail.

    In any case, you should regularly create a backup of your database file (which KeePass recommends when creating a new database). There are many different ways for creating backups; use one that suits your scenario. If you aren't using another backup solution already, you could do it using a trigger or using a plugin (there are multiple backup plugins listed on https://keepass.info/plugins.html).

    Best regards,
    Dominik

     
  • Dominik Reichl

    Dominik Reichl - 2024-04-18

    Just to clarify: when the error message appears, the target file might be corrupted (which is stated in the error message), but the data in memory is of course not corrupted. You can save it to a different file (e.g. on a local hard disk), without losing any data.

    Best regards,
    Dominik

     
  • Ely

    Ely - 2024-04-18

    About the backups... I always backup the main database after sync... but it's harder for me to backup the remote database.

    When the process gets interrupted, the remote database really brakes... When I manually copy it to the main equipment and try to open it, I get an error: "Failed to load the specified file!. The file is corrupted."

    (I even tried, just for testing purposes, to open it in Keepass2Android. The message I get there says: "The input is not a valid Base 64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters")

    What is missing in Keepass is an option to copy the remote database locally and save it as a backup, before the process of synchronization (and would be nice an option to say if you want to override it always or add the current time to the name, or something)

    At least to add a placeholder to Keepass with the remote path when you try to sync. If there where one, using a trigger before sync it would be easy for me to backup the remote database, "just in case of an error".

    I hope I've made myself clear.

    Ely

     
  • Paul

    Paul - 2024-04-19

    If you store the remote database location in a KeePass entry you can access it to use in a trigger / sync. I would use the URL field.

    cheers, Paul

     

Log in to post a comment.