Restore logseq graph from .transit file

Update Edit

what I encountered is graph and logseq app both lost the data. if your logseq app keeps the latest update version, there is no need to manipulate the .transit file. If the .transit file is also updated with the outdated version, this post cannot help you. If graph is really important, git or ‘timely sync’ is strongly encouraged.


original post

finally, I’ve recovered most files without programming a tool in clojurescript :grinning:. maybe I will learn this language sometime later.
here is what I did if it can help some one in the future

  1. go to ~/.logseq directory, find xxx.transit file.(I didn’t recover all of my data for this file is saved three days ago and I suppose this saving action is mainly triggered by a normal quit app). this file location may diff in different os, check first. and then save a copy in time. as this file may be updated by logseq, for example when quit. we have to make use of the time gap and inconsistency of state between .transit file and graph directory as logseq can restore it’s consistent state automatically and drop the data we lost

  2. quit logseq

  3. duplicate the saved copy of .transit file in the same origin directory with another name. logseq just join the full directory of graph to name the .transit files. and relaunch logseq.

  4. the exciting moment came, in the dropdown menu of graph selection(left top), the extra graph(it’s name is determined by the name of .transit file which is what you give in step 3). Just select and switch to the new graph, and you will see the lost pages.

  5. ignore the error tips logseq display, as the new graph has a new name, but the derived directory (notes content )does not exist. you can then export or just follow the refer link Can I Convert Cache to Graph? - Questions & Help - Logseq. run logseq.api.download_graph_pages() in the js console of dev tools of chromium.

  6. a zip archive is downloaded and that’s your lost pages and journals. regarding asset(eg. some pdf file), it just gets lost in the void.

tips:

  • quit logseq normally may helps sync and persist graph state in local disk.
  • Do not force quit logseq and be patient especially when doing sync.
  • remember not to trust any software totally, especially when you know not much about it. and make a backup in time/scheduled.
  • when restore the markdown files, diff is a great tool and helper.
2 Likes