How to sync your Logseq graph across devices

As Logseq saves all of your notes and settings in plain text files (in Markdown format), any file sync service will enable you to synchronize your Logseq graph across several devices. However, we’re working hard on building our own sync service so you have a one-stop shop for all of your Logseq needs.

One current caveat when working with several devices on the same Logseq data is that you can only have one device use the data per time. So, if you use the Logseq mobile app and want to continue working on your desktop, you first need to make sure the data was synced from your mobile device. Only then should you open the Logseq app on your desktop. It maybe necessary to re-index your graph on desktop to make sure all recent changes are loaded in.

This article is a stub. Please help improve it by adding (links to) tutorials and how-to articles about different syncing solutions.

9 Likes

I am just wondering if there are any other (however temporal) advices for safe syncing across devices. Besides closing Logseq on one computer (thus saving files) before launching Logseq on another computer with synced data, is there anything that a user should do in order to avoid problems?

In particular, I keep encountering syncing errors with pages-metadata.edn. I use owncloud for syncing, but based on occasional reports here also dropbox, onedrive and other syncing tools suffer similarly.

Syncing is indeed an issue that creeps up with several providers. That’s the whole reason we’re working hard to launch our own (encrypted) Logseq Sync service. It should go into closed beta this summer and address many of the issues that plague third-party syncing solutions.

8 Likes

Still, is it possible to give (however simplified) explanation of the reason for these problems? After all, all Logseq data is just text files, right? I have not set up any exclusion of files to be synchronized (other than the usual guys such as backup files), so how come that we are experiencing these problem? In which technical aspects is the Logseq situation different from other applications that also have a bunch of configuration files and a bunch of data files? Some time stamping tied to the particular piece of hardware or what?

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