capacitor-community / capacitor-community/sqlite

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

Open
#613 2 comments 1 reaction 0 assignees View on GitHub
bug/fix needs: triage
Dominant language
Swift
Stars
661
Forks
158
PR merge metrics
No merged PRs in 30d

Description

**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 https://github.com/capacitor-community/sqlite/blob/891377f344924de80003287f172de24984e8b74b/ios/Plugin/Utils/UtilsFile.swift#L50

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 (https://github.com/capacitor-community/sqlite/issues/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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.