I'm using Logseq with iCloud, but experiencing data loss or file conflict errors. What's going on?

It’s not rare that iCloud would generate duplicated files

It’s not a Logseq specific issue according to reports like:

Also, there are reports that iCloud doesn’t notify apps on file updated. It’s not limited to Logseq. A common solution maybe clicking the “refresh” button in the dropdown list, or restarting the Logseq app.

May be related to iCloud’s stability and conflict resolution for small files. Logseq relies on file-based storage for notes, which requires per-file sync with iCloud. Unfortunately, iCloud can sometimes have difficulty with small-file sync and conflict resolution.
According to our investigation, it’s likely that iCloud “stuck” at uploading a small file without any reason. A general solution to “refresh” the update is to kill and restart the iCloud process.

Some suggestions

  1. Monitor the sync status of your iCloud files. If you notice that a file is stuck in syncing / not syncing correctly, try manually triggering a sync or refreshing the file on your device;
  2. Avoid editing files on multiple devices at the same time. Confirm the sync status before you switch the editing device;
  3. Periodically backup your Logseq notes.

How to recover my data?
Check the logseq/bak folder under your graph’s directory

For iOS users: Alternative to iCloud?
To provide a care-free user experience on iOS is one of the motivation for developing our own sync service:
Logseq Sync service is under beta
For pro-users prefer Git, Working Copy is working well with Logseq on iOS according to reports
Most 3rd-party sync services cannot be accessed by Logseq. It’s a common issue for all note-taking apps with file storage.

As maintainers of Logseq, we are always looking for ways to improve the stability and reliability of Logseq’s compatibility towards 3rd-party sync services. However, in the case of iCloud, it is the Apple’s black box of implementation block our efforts on keep compatible with iCloud. As Logseq is open-sourced, any suggestions & comments on the code base is welcome