realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Add option to exclude realm from iCloud backup

Open c-goettert opened this issue 3 years ago • 4 comments
trafficstars

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 avatar Dec 08 '21 16:12 c-goettert

@c-goettert Thank you for the suggestion. I see three possibilities:

  1. Always exclude Realm files from iCloud backup
  2. Only synced Realms from backup
  3. 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?

kneth avatar Dec 09 '21 14:12 kneth

Hi @kneth, thanks for the fast reply! I would prefer a configuration option (3), as it's the most flexible one.

c-goettert avatar Dec 09 '21 15:12 c-goettert

Any updates on this?

marcosrdz avatar Feb 18 '24 21:02 marcosrdz

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.

kraenhansen avatar Feb 19 '24 12:02 kraenhansen