Deleted copies of notes deleted all files original and cloned

Version 2.4.3. I have done a, search of duplicate notes and found quite a few. The duplicates specifically were bracketed separating them from their clones. I searched for only the bracketed items and then deleted them. Afterwards, all copies, original and clones were gone
I tried syncing but nothing was there. How can I recover these files?

I'm not quite sure I understand what happened. I assume you deleted these notes from within Joplin, not your sync target directly?
If the notes were deleted from Joplin then they will also have been deleted on the sync target.

What was the exact search you ran?

Deleted from within Joplin. Searched for all items with the brackets that wee shown as the duplicate notes. The search showed all and only the duplicate notes in brackets. I deleted them and then when I went to look at the original notes of the duplicates, they were gone. I vaguely remember that Joplin just told me I had duplicate notes which were shown in brackets. I don't remember frankly if it was [ ] or this ( ). Thanks for your time here... Jeff

I assume you don't have a local backup of any kind?
Where did you see these brackets exactly? I'm afraid I've not seen that specific functionality so far. Or is it some kind of plugin functionality?

Either way, if your notes have been fully deleted you might out of luck. However if you have note history enabled you might still be able to get hold of the data from the database but it might be a fair bit of work to restore them. To start with you should probably make a backup of your sqlite database so you can connect to it without fear of making changes in your live one.

There are probably far better ways of doing this and I'm very happy for somebody to correct me but it might be worth connecting to the joplin database directly and doing an sql query for your note to see if it still exists
e.g.
I had a note called "hashes" which I deleted.
If I go to the deleted_items or item_changes table you can see various item_ids which you can then reference in the revisions table to see previous versions of the note that existed up until it was deleted.
Or you can search directly in the revisions table in the title_diff or body_diff field for certain criteria if you know exactly what you are looking for.
You would then need to copy those fields and remove all the extra stuff then make your notes again from scratch.

If you can know the note ID, you can also restore it using the command restoreNoteRevision NOTE_ID from the command palette. I've added that some times ago for desperate situations.

1 Like

Thats a much better solution, it seems the the item_id from revision or in deleted_items can be used as the note_id if I'm understanding the functions in revisionService.ts and Revision.ts correctly? It seemed to work for a test note I made and deleted.

Yes indeed in this cases item_id would refer to the note ID so it can be extracted from there.

In that case @fallendaemon it seems you will still need to have a dig around in the database but it is at least easy to restore the notes once you find them.

(Sorry if anything here is obvious but it might be helpful to people in the future). You will need to open your Joplin database. In Joplin go to Help > Open Profile Directory and copy the database.sqlite somewhere. To open it you need some kind of sqlite browser of which there are many, sqlite studio is probably the easiest.

So, open the deleted_items table and go to the data tab and look for the various item_ids. You can then query them in revisions (just paste the id into the filter box) to make sure they are the correct ones (or don't and just restore a bunch then re-delete them later if not needed).

Open the command pallette (ctrl + p) and type restoreNoteRevision followed by the note_id e.g.
restoreNoteRevision 8066304e11c641428d001c1cdaffcb70
then hit return and it will tell you if it was successful.
Rinse and repeat for all your other notes.

There is also a guide by @theCollectiv if that makes better sense than my ramblings

No instruction or help is ever a waste. Many thanks for this direction.

I've added a slightly more comprehensive guide here if you need it.

1 Like

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