Skip to content

bug: Data loss risk on iOS - the Database folder is excluded from backups #613

Open

Description

@gregzo

Plugin version:
6

Platform(s):
iOS

Current behavior:
On iOS, our app specifies it's own iOSDatabaseLocation directory:
Library/Database

But I see that, just after the directory is created, the isExcludedFromBackup flag on that directory is set to true. See

try UtilsFile.setExcludeFromiCloudBackup(&dirUrl,

Because of this, none of the databases in that directory will ever get backed up, to iCloud or to a computer. I'm pretty sure that this will also exclude the files from a direct device to device transfer.

As a mitigation, our app explicitly sets the flag back to false, but we weren't expecting the behaviour. As a result, our users are at risk of data loss if they transfer data to a new iPhone before updating our app. Not cool.

Solution

I see that historically, the flag was set purposefully to hide the database from iTunes (#207), but that is completely misguided as in practice, there's now no way for the dbs in that folder to be transferred to other devices as long as the flag remains...

Happy to discuss. iOS backups are a specialty of mine, used to work in that domain specifically.

Activity

  1. added
    bug/fix
    on Jan 6, 2025
  2. gregzo commented on Jan 6, 2025

    @gregzo
    Author

    Update: I see that the issue only occurs if iOSDatabaseLocation is specified in capacitor.config so most users of the plugin will likely never see the bug. Still, very unexpected behaviour in my opinion - databases SHOULD be backed up by default, especially since that is the default data transfer mechanism on iOS to set up a new device, via iCloud backup or local backup or direct transfer.

  3. svolke commented on Mar 11, 2026

    @svolke

    Update: I see that the issue only occurs if iOSDatabaseLocation is specified in capacitor.config so most users of the plugin will likely never see the bug. Still, very unexpected behaviour in my opinion - databases SHOULD be backed up by default, especially since that is the default data transfer mechanism on iOS to set up a new device, via iCloud backup or local backup or direct transfer.

    The problem is more urgent than that, I guess. Most users will probably copy the capacitor.config from the readme. There, an iOSDatabaseLocation is stated. So I think, the problem will be relevant for a lot of users :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/fixplatform: ios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions