Explanation of .lock, .management and .note?

When using Realm in React Native you have your database file, for example default.realm, and then you also have default.realm.lock, default.realm.management and default.realm.note as well.

I can’t see an explanation of these in the docs (unless I’m missing it). Can someone give an overview of what they are for (I can take a pretty good guess for the lock file but I’m not sure about the others).

I’m asking in the context of doing some DB backups in one of our apps - is the default.realm on it’s own sufficient or do (it seems to be as far as Realm Studio reading the data) or are the others needed (maybe only in certain situations?)

Hi Liam,
As you probably guessed, the lock file is used to coordinate multi-process writes. The files inside of the .management directory are used for file lock emulation on platforms which do not provide sufficient locking primitives (Apple devices). The .note file is a pipe used to communicate notifications.

If you know for sure that nobody is using the .realm then you can do simple file system copy of just the Realm file. But if there is any chance that someone is writing to it during the copy, you may end up with a corrupted backup if the file system copied partially written data. For this reason, I recommend using our copy API to make the backup which safe to use even if another process is modifying the Realm. See Class: Realm

3 Likes

Thanks James, that helps! :slight_smile:

I’ve just noticed it is also summarised in the docs but I’d missed it: https://docs.mongodb.com/realm/sdk/react-native/fundamentals/realm-database/#realm-files

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.