# How can I re-import Deleted Files?

**URL:** <https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587>\
**Category:** Support\
**Created:** [28 September 2022 18:58 UTC](https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587 "2022-09-28T18:58:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![arion279](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/arion279/32/15088_2.png) [@arion279](https://discourse.joplinapp.org/u/arion279)\
**Post date:** [28 September 2022 18:58 UTC](https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587/1 "2022-09-28T18:58:34Z")

</div>

- version 2.8.8
- operating system Windows 10

Hi, I started Joplin by creating notes into a single profile. I set up OneDrive as the sync target.

Then I realized I wanted my notes to be separated by concern (home life, business 1, business 2, etc).

I then created 2 more profiles (Default being the current one, plus 2 more for the 2 businesses). I exported notes accordingly so I started out basically with 3 copies of the same profile... or so I thought.

I then went back and started deleting irrelevant notes from the respective profiles, intending to have just the relevant notes in each profile. I unfortunately started with deleting notes for the meatiest profile away from the less meaty profile. I thought I was just deleting notes from a specific profile but when I looked at the other profiles I discovered that those notes were being deleted throughout all profiles! All the profiles had the same data!! So I deleted a ton of very valuable notes!

I did some digging and found that (thank goodness) there appears to be a Note History feature and many notes are still in the ether located at "C:\Users\USERNAME\OneDrive\Apps\Joplin". There are a lot of md files in there, and when I opened up a few, I can see content from notes that were deleted.

However, these md files are not standard, and have odd formatting as follows:

id: 0a4a56e02bae4c9a3510ab23413afac0  
parent\_id: 859bd8dc7ef14c0db2e677735a34e3f6  
item\_type: 1  
item\_id: 55d805eef1ff41dd98ecfc2f3570a062  
item\_updated\_time: 1663211544309  
title\_diff: ""  
body\_diff: "[{"diffs":[[0,"lHost\>\\n\\n"],[1,"...CONTENT OF MD FILE..."]],"start1":375,"start2":375,"length1":8,"length2":424}]"  
metadata\_diff: {"new":{},"deleted":}  
encryption\_cipher\_text:  
encryption\_applied: 0  
updated\_time: 2022-09-15T03:15:00.764Z  
created\_time: 2022-09-15T03:15:00.764Z  
type\_: 13

I've read that Joplin modifies the md files to accept additional functionality so I believe I understand why it's formatted this way, however, I've tried to import the individual md files and md directories, both with and without frontmatter, and Joplin imports this odd formatting verbatim, and the note title is the hash "id" parameter above.

At this point I just need all of my original deleted data back and I can reorganize my profiles properly. How can I get the saved copies of the md files back in my Joplin so I can save properly? Or is there a tool out there that can take these modified MD files and give me back a non-Joplin-modified MD file so I can manually add the MD content back in?

Of course, I will be backing up properly and using profiles in the right way from here out-- but I just need to fix this before proceeding.

Any direction please help!! I've invested a ton of time into creating beautiful and helpful notes that are now _POOF_ gone.

THANK YOU

---

<div class="post-metadata">

**Author:** ![Daeraxa](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/daeraxa/32/6172_2.png) [@Daeraxa](https://discourse.joplinapp.org/u/Daeraxa)\
**Post date:** [28 September 2022 19:24 UTC](https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587/2 "2022-09-28T19:24:53Z")

</div>

> [@Restoring Deleted Notes](https://discourse.joplinapp.org/t/restoring-deleted-notes/21304):
>
> Note: The method described here is an advanced one. First consider trying [these more simple methods](https://discourse.joplinapp.org/t/how-to-recover-your-notes/46201). Restoring Deleted Notes This is a step-by-step instructional guide on how to restore accidentally deleted notes in Joplin using the restoreNoteRevision command as well as how to find your missing notes in the Joplin database. This assumes that you do not have a note backup of any kind (other clients, profile backups, JEX export etc.) and you have otherwise run out of options to get the data b…

I wrote a guide on how to use the revision service to restore deleted content. It is a very manual process but it does work.

---

<div class="post-metadata">

**Author:** ![arion279](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/arion279/32/15088_2.png) [@arion279](https://discourse.joplinapp.org/u/arion279)\
**Post date:** [28 September 2022 22:23 UTC](https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587/3 "2022-09-28T22:23:39Z")

</div>

This was IMMENSELY helpful! I was able to recover every note by the instructions you've provided. I can't thank you enough!!!

This manual behavior makes me feel there is a way to execute this with a script. Is the `restoreNoteRevision` command available in the command prompt by chance? Then a user could have a text file of item\_id's on separate lines and have a script iterate over them and execute `restoreNoteRevision` on each id in the text file.

I'll add a few comments that I think would help the next unfortunate soul that has to learn this hard lesson.

Since item\_id is not a unique field, scanning the list of item\_id's will result in potentially multiple versions (revisions) of the same item\_id. Trying to keep track of which item\_id's you've already imported can be a pain the longer the list is. SQL can trim this list down so only unique item\_id's are shown.

While using SQLiteStudio, you can click Tools -\> Open SQL Editor and run the following SQL:

`SELECT item_id,title_diff,body_diff,created_time FROM revisions r1 WHERE r1.created_time = (SELECT max(created_time) FROM revisions r2 WHERE r2.item_id=r1.item_id) ORDER BY created_time DESC`

This will show only unique item\_id's instead of multiple sets of them. Please note this SQL returns only the latest revision per item\_id, though it really doesn't matter when importing. It does matter though when you are trying to visually scan the database for specific text in the title\_diff or body\_diff fields. Then you may want to not run the above SQL.

Anyway, thank you so much again!

---

<div class="post-metadata">

**Author:** ![arion279](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/arion279/32/15088_2.png) [@arion279](https://discourse.joplinapp.org/u/arion279)\
**Post date:** [28 September 2022 22:31 UTC](https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587/4 "2022-09-28T22:31:23Z")

</div>

Now that my data is back, this brings up an issue. I just opened a different profile and noticed that because I am connected to OneDrive sync, the OTHER profile just finished updating the recent changes too! I thought profiles were supposed to segregate concerns (like work vs personal) in different databases? Is there a way to allow Joplin to use OneDrive for sync of both profiles, but not sync with each other? Seems any change in one profile overwrites the other profile.

---

<div class="post-metadata">

**Author:** ![Daeraxa](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/daeraxa/32/6172_2.png) [@Daeraxa](https://discourse.joplinapp.org/u/Daeraxa)\
**Post date:** [28 September 2022 22:40 UTC](https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587/5 "2022-09-28T22:40:20Z")

</div>

Glad to see the restoration worked, I intentionally gave instructions manually via the UI to not scare people off because it involved scripts or complicated sql statements, I'll have a look at adding that query somewhere (it is a wiki post so in theory anyone can edit it but I suspect as you are new it might not let you yet, if it does let you then have at it (if you want)).

> [@arion279](#):
>
> Now that my data is back, this brings up an issue. I just opened a different profile and noticed that because I am connected to OneDrive sync, the OTHER profile just finished updating the recent changes too! I thought profiles were supposed to segregate concerns (like work vs personal) in different databases? Is there a way to allow Joplin to use OneDrive for sync of both profiles, but not sync with each other? Seems any change in one profile overwrites the other profile.

It doesn't create a new "sub-profile" on the sync target, each profile is essentially an entire profile in its own right.  
So for example I could create have my main `personal` profile on desktop and make a child `work` profile but each has its own sync target.  
That means I can have another client that _only_ syncs my work profile and another that _only_ syncs my personal profile - they are all independent.

Unfortunately this is where it falls down on OneDrive and Dropbox in particular. It is easy to create your own subfolders on WebDav, NextCloud, Joplin Server etc. to hold your extra profiles (e.g. `www.mynextcloud.com/nextcloud/files/Joplin/Personal`) but on Dropbox/OneDrive it just puts it into a single folder that can't be changed (as it does it via the API).

I actually made a post about this here - [Joplin 2.8 is available! - #10 by Daeraxa](https://discourse.joplinapp.org/t/joplin-2-8-is-available/25943/10)

---

<div class="post-metadata">

**Author:** ![arion279](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/arion279/32/15088_2.png) [@arion279](https://discourse.joplinapp.org/u/arion279)\
**Post date:** [28 September 2022 23:11 UTC](https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587/6 "2022-09-28T23:11:36Z")

</div>

Thanks for the clarity. I see-- perhaps that info is shown somewhere in the Joplin guides but it is not obvious when using the Sync Wizard. Might be worth adding a warning message if the user selects one of those methods to let them know they will overwrite other profiles if these methods are used. I'd imagine this is a somewhat common case (keeping work and personal separated) so adding an extra cautionary note may be helpful. Anyway-- thank you again!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex028/uploads/cozic/original/3X/1/c/1c948e33314e232a0927789508474d8624f4270b.png) [@system](https://discourse.joplinapp.org/u/system)\
**Post date:** [28 October 2022 23:11 UTC](https://discourse.joplinapp.org/t/how-can-i-re-import-deleted-files/27587/7 "2022-10-28T23:11:52Z")

</div>

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