Saving With KeePass or KeePassXC Causes Database To Be Unusable on iPhone/iPad

Sometimes there can be some issues with iOS Files based databases and KeePassXC / KeePass and cloud drives. This can sometimes present itself as errors like:

- "The database is located in Recently Deleted"
- "The database was 'Removed from iCloud' on another device"

Solution
The solution to this is to turn off "Safe Saving" in KeePassXC or "File Transactions" in KeePass. You can use the instructions below to do this:

KeePassXC

  • Go to Settings > General > Basic Settings > File Management
  • Switch on Use Alternative Saving method
  • Choose Directly Write to Database File (Dangerous) in the dropdown.

KeePass

  • Go to Tools > Options > Advanced > File Input/Output Connections
  • Switch off Use File Transactions for Writing Databases

Alternatively if possible you should try to use the native Google Drive, Dropbox, OneDrive or other native methods to add your database instead of the iOS Files method. These use different methods to keep a reference to your file that doesn’t break when KeePass / KeePassXC updates.

iCloud Users
Another solution that works much better (on iOS at least) is to use the official Strongbox iCloud folder. This is a dedicated folder and Strongbox will automatically detect and sync anything here including files updated by KeePassXC. The folder should be in the root of your iCloud Drive with the Strongbox icon on it. If you don’t see it you can create it by adding a new iCloud database via Strongbox. You may also have deleted that folder by accident and you'll need to recreate it:

I deleted my iCloud Strongbox folder and now I can't create a new iCloud database

Technical Explanation
Basically what’s happening is that Strongbox’s reference to the database becomes invalid because of the way these Desktop clients save the database. They create a new temporary file and swap it in/rename it instead of updating it in place. This is sometimes known as "Safe Saving", however for most modern Cloud Drives this seems to be no longer a concern as when an incomplete file transfer doesn't lead to corruption. Most cloud drives work on atomic transactions internally.

Jan 5, 2024