How to sync your Logseq graph across devices

Yes and no. Logseq works on top of a Datascript database, which writes to Markdown files. When you have Logseq open on multiple devices at once, you have two database instances writing to the same file. When a cloud service sees two versions of the same file, it can get confused.

So while Logseq works with text files, there’s a slight lag between the database and the actual file.

3 Likes

Does any recommendation follow from this to minimize the probability of synchronization conficts?

Typically I am running Logseq on my laptop on my commuting to work. Then I step into the office, my laptop gets connected to the network, I quit Logseq, give a few minutes to the laptop to synchronize with my cloud. Then I launch the desktop PC, give it a minute or two to synchronize with the cloud (download the updated files), and only then I launch Logseq on the desktop PC. And yet some pages-metadata.edn issues appear regularly.

GitHub might be a solution, although iCloud has been very stable for me on Apple devices in the past few (4) versions.

2 Likes

Hi all! I started using GitHub as repo few days ago. I sync among a Windows PC, iPhone and iPad.

I also encounter the pages-metada.edn issues, even being careful of not opening the app in more than one device at a time.
Digging a little over it, I found that the LogSeq windows app don’t save changes to pages-metada.edn at the same time that changes are made to a journal.

From my observation this is what happens:

  • I add a line to today’s journal.
  • Logseq saves that update in the MD file instantly.
  • When my next “auto commit” time, LogSeq commits and pushes the change to GitHub.
  • I then close LogSeq
  • At close, LogSeq writes/updates with a new timestamp the line corresponding to my journal page “block/updated-at xxxxxxxx” in pages-metada.edn.

Hence, that change is not committed/pushed unless I open LogSeq again (or manual commit via GIT).

I presume that if you close LogSeq and go to your iPad/iPhone and make changes, there will be a conflict the next time you open the desktop app, as you will have contradicting pages-metada.edn file.

For me the error that appears when I open LogSeq is innocuous as I didn’t make other changes and I can dismiss and continue working as if nothing had happened.

Makes sense?

I am thinking on a way to troubleshoot this. One would be to force a commit/push when the app closes.

Thoughts?
Danny.

2 Likes

Welcome to the community @DanielDan!

This post and the comments are meant to create documentation about syncing between devices; it’s not a troubleshooting thread that’s monitored to help people individually.

If you have a question specific to your situation, please create a separate post in #questions-and-help. That will make it easier to zoom in on your situation and it’s monitored by much more people than the comments of a documentation post.

1 Like

I use SyncThing to monitor and sync my Logseq folder. It’s fast, encrypted, cross-platform, and peer-to-peer (doesn’t need a server).

It can use O/S filesystem hooks and sync nearly instantly on file write and detects change collisions. It has an intelligent file deletion queue.

About the only thing i could imagine being better would be real-time live multiuser Google Docs-like editing or a server that natively understands Logseq database transactions.

Dave

6 Likes

@dvorme is one of your devices iOS by any chance and if so are you using Mobius?
If so could you please advise how you overcame this issue "Please choose valid directory" issue on iPhone

1 Like

Just simple way is nextcloud free hosting services…
signup new nextcloud account 2gb to 8gb free hosting services fully works with nextcloud clients (win/mobile/mac) . Nextcloud client also runs as portable (for restirected pc etc) And assign folder of logseq graph to nextcloud folder . Thats it. Instant sync … One problem… doesnt work with iphone because of ios…
as a result we have also same problem with The Syncthing

2 Likes

Hi all,

I am also encountering sync problems and experienced some data-loss (manually recovered either by the Nextcloud version management or Syncthing backups), so I’m finding it not reliable enough. Also, this is the first place I read (in Rameses’ response, I asked on the Matrix channel as well) about the Logseq file/database workflow and why that might produce some sync conflicts, and the need to close the app in one place before opening it in another. I’m missing a bit more thorough documentation on this and the “Refresh” and “Re-index” functions, to better understand how Logseq works and be able not to break it…

I still feel unsure about file integrity and sync, but will try to make sure that I avoid having the app open in many places at the same time. I wanted to ask though: how do you close the app on Android? Just “close” form the running apps list? Does this trigger a “file write” from database to actual files, that would then be propagated elsewhere? Just to minimize my chances of generating sync conflicts…

Thanks in advance!

I use SyncThing:

Yes, thanks for your reply, I use Syncthing myself as well and that’s mainly what has enabled me to manually recover from data loss. Key for me here is “almost instantly on file write”. I would rather Logseq worked directly on files so that this “middle-layer” would be avoided, as that’s what I think makes sync much more complex—and I don’t get what purpose it serves at all btw (but I’m not a developer so that probably also doesn’t help).

I believe that dispensing with that intermediate layer is not possible given the decision taken at the time to adopt the current architecture. I think the way to fix this lies elsewhere, as fixing this issue that way would not outweigh the benefits that this model offers. I suppose that the work that developers are currently doing regarding the synchronization between devices and the service via cloud services goes in that direction, but I don’t know.

Still, in any case, I think that maybe a plugin that captures the raw stream directly from the Hoocks to a FIFO file, could be useful to manage yourself the problems of differences between versions or other possibilities.

1 Like

Sure, and I’m not questioning the decision, just in case it seemed so. Thanks for your detailed overview, I will have a careful look at it ! (adding this to my Logseq journal right away :blush: )

1 Like

BTW, check this:

2 Likes

Hi @Ramses, is there a section dedicated to Logseq Sync in this forum? I’m a Logseq backer and I started using Logseq Sync a few weeks ago. I am very happy with it except that I still get the same error message on launch about the file name format despite using the triple-lowbar format in the settings. Do you know what to do in order to fix it?

What’s the version of Logseq you are using @cyan0245?

Have you tried reset the remote graph?

Can you provide more details?
Can you send some screenshots on the notification & the file names to this email: junyi@logseq.com

Thanks for your answer @Junyi_Du, I really appreciate it.
I run Logseq 0.8.18 on both an Apple M1 Max with macOS Ventura 13.2.1 and an iPhone with the last version of iOS.
Here are some scrennshots of the warning I get on Logseq launch on both devices.





It seems that errors come from some pipe ou € sign in the file names while I’m not sure about it. How could I change these file names without loosing the link in Logseq? Would it be safe to proceed manually this way?
Thanks for your help :wink:

Oh seems they are asset files. It’s not considered by the in-app conversion UI yet. You may have to remove the special characters (like | and : ) from the file manually :melting_face: sorry for the inconvenience
A general tip for naming files: Naming Dropbox files and folders - Dropbox Help

These are files that I’ve picked up here and there. I will clean up their names manually. But for the future, isn’t Logseq supposed to automatically clean up file names when you add them as an asset?

This tutorial doesn’t make any mention of the importance of encrypting your data when pushing it to remote repos, or cover steps to do that.

See this link for a discussion and brief how to in the Obsidian community: [Mobile] Sync with git on iOS for free using iSH - #17 by evergreensnow - Share & showcase - Obsidian Forum

Have brought this up in other threads here (Alternative way of git syncing on iOS using a-shell for free - #10 by smart.pen5644).

We need a good, easy, and secure way to sync their data across devices. Am willing to pay for Logseq sync once that works without issues.

2 Likes