[linux] advice to help me recover my lost database?

I've already asked on the subreddit for Joplinapp but could use more input please:

I was using the flatpak version of Joplin. Everything in my home directory got nuked which included the Joplin flatpak files. What I did was use photorec to try and restore the files. I have about 200 .sqlite files which have all been renamed fxxxxxxxxx.sqlite with photorec during recovery so I can't just search for database.sqlite.

I tried opening every single one after another in a sqlite viewer and couldn't find the Joplin db unfortunately. Three of the files did have mentions of my notes but I think that was just flatpak or linux logging something. I then tried opening them manually in notepad (on my win10 machine since my Linux one is out of commission atm) and comparing it to a fresh Joplin db.

Is there any chance it could be saved as another file extension? A lot of the .sqlite files I see are malformed and could be from various applications/packages.

I was in the process of using joplin when the delete happened so maybe it's a sqlite temp file somewhere if it saves it as another extension before writing it to the database.sqlite?

Thanks! I really don't want to lose months worth of notes, most of which I wouldn't even remember because that's why I was using a note taking app in the first place.

I don't suppose you have an up to date sync target you could sync a new client to (after backing it up).

You could loop on the .sqlite files and run something like sqlite3 ~/.config/joplin-desktop/database.sqlite 'select id, title from notes limit 1' and see which one returns something. However, you would still lose all the resources as they are not stored inside the sqlite database, so indeed if you have another client it's best to restore from that.

Unfortunately I did not have a backup. I was transitioning my files from Windows to Linux. Part of that was deleting all of my .txt notes and I wrote them out in Joplin then deleted the .txt notes lol.

By resources do you just mean images? I didn't have images, links, music, etc in my notes. It was pure text.

In those 2-3 sqlite files I looked in that had remnants of my notes, I don't know what to make of. It had random notes from different notebooks but not all of them and also had other packages mentioned which is why I think it was some sort of log file.

I will try the suggestion of running a loop on it. I'm confused by the first part " ~/.config/joplin-desktop/database.sqlite" Right now all of the ~200 recovered .sqlite files I have are in a random folder created by photorec. Is that first part supposed to be used as a template or something? Wouldn't that only look at database.sqlite?

Thank you both for your responses!

The path was just an example - you need to loop on the files with something like this:

for f in *.sqlite; 
do 
    sqlite3 "$f" 'select id, title from notes limit 1'
done;

Would you have any more insight or documentation about how Joplin saves files? I haven't managed to recover my notes yet. It's a strange situation. There's about 200 .sqlite files that photorec recovered and I'm seeing bits and pieces of my notes in various files throughout the files when I open them in Notepad. As if they are mangled with other sqlite stuff. I cannot actually open most of the files with a sqlite browser since it says they are malformed. For ones where I can open them and see parts of my notes it's a Mozilla Firefox sqlite browser file. In some cases the start of the files look like what you would expect for database.sqlite in other cases the notes are at the very end cut off. This really sucks as I had over 60 notes in Joplin. Thanks!

No sorry, I don't have anything more to suggest. If all you have left are corrupt databases, probably your only option is to use an hex editor and try to extract the data from it manually. Maybe there are tools to restore a corrupt db so you could search for that.

There are tools to recover data from sqlite databases. A quick google search shows some results but looks like most if not all are commercial tools.

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