realm-js
realm-js copied to clipboard
Add option to exclude realm from iCloud backup
Problem
Some apps might want to exclude realm from the iCloud backup. Currently there is no configuration option to achieve this behavior. I am aware that there are manual ways to solve this, e.g. manipulating the resource keys of files created by realm. However, I can understand developers who would rather not make such adjustments, as they may not be able to fully understand the effects. E.g., Apple writes in the documentation about the corresponding NSURLIsExcludedFromBackupKey parameter:
Set this property each time you save a file because some common file operations cause this property to reset to false.
It also feels to me that this option should be configurable via Realm itself, since Realm is a database with its own synchronisation capabilities. React Native Async storage for example offers a configuration option for this purpose. Also, I've seen that for some files there is already an exclusion rule defined (see PR). Maybe you can tie in here?
Solution
Provide a configuration parameter to exclude realm file from iCloud backup.
How important is this improvement for you?
I'd like to see it, but have a workaround
@c-goettert Thank you for the suggestion. I see three possibilities:
- Always exclude Realm files from iCloud backup
- Only synced Realms from backup
- Add a configuration option and let the app developer to decide
I can't give a timeline for when we add it, but if you were to pick, which one of the three above would you prefer?
Hi @kneth, thanks for the fast reply! I would prefer a configuration option (3), as it's the most flexible one.
Any updates on this?
Set this property each time you save a file because some common file operations cause this property to reset to false.
Since we memory-map the file, I'm not 100% certain what "save" means in our case, it might be required on every flush, which would likely be detrimental to runtime performance 🤔 But I don't think that would be required.
If we want to follow the approach that react-native-async-storage and Realm Swift is using, it seems we only need to (optionally, based on the configuration) call into Swift code once when opening the Realm.