Tessus' Joplin Cleanup Script for Orphan Resources Nuked Everything

Operating system


Joplin version


Desktop version info

Joplin 2.13.9 (prod, linux)

Client ID: 490a9b87de5041c7b474ee44e9ea56ac
Sync Version: 3
Profile Version: 44
Keychain Supported: No

Revision: 1bbec44

Conflict Resolution: 1.2.3
Enhancement: 1.2.1
Freehand Drawing: 1.12.1
Menu items, Shortcuts, Toolbar icons: 1.1.0
Note Tabs: 1.4.0
Simple Backup: 1.3.3

Sync target

Joplin Server


Markdown Editor

What issue do you have?

I used Tessus' script for cleaning up orphan resources. I made a back-up before (3Gb), and my resources folder decreased from 34Gb to 24Gb, which was alright. I have two questions:

  1. Why won't my resource folder reduce close to the size of my back-up (simple back up plugin)?;
  2. Why does the script not protect older JPG or PNG images? More recent photos uploaded to Joplin have been saved, but older photos, or screenshots, were deleted.


It seems Simple Backup doesn't back up resources, and it only backs up typed text. Actually, the most recent back up didn't store all my resources before I used the scripts. The reason for this was the backup was set to a 24h interval and overwrote my "good" back up.

I found a back up from the summer which stored my old resources. Is there an easy way to reconcile the changes? This is pretty disastrous.

I suppose I lost a few years of resources. RIP university work.
Since the scripts are unreliable and damaging, what is a safe method of reducing the resource folder size?

The more I'm clicking through my notebooks, the more I'm realizing that the script arbitrarily deleted photos instead of by date. Some old photos are saved, some new ones are deleted. Thankfully, the PDFs and data sheets I have saved are still unaffected. Nevermind. This is brutal. My PDFs and other files are all dead too.

What will happen if I import the old back ups into my current profile? Will this make loads of conflicts that I have to manually choose which ones to keep?

I'm making a new profile, importing all of the JEX exports, and seeing what I can salvage. Some stuff is certainly gone forever.


I just finished merging two backups together and as I went through every single note, I discovered that the script basically destroyed everything except plain markdown text. Tessus should consider removing that script repo from his github. That's a dangerous script and I have no idea how it "works" for others.

I originally posted this here a few days ago. It should be relevant here.

They [orphaned resources] should be automatically deleted:

joplin/packages/lib/services/ResourceService.ts at ee18271f9b8bd9a4ce48891ac1963d3b323a8f66 · laurent22/joplin · GitHub

From the above code, it looks like they are deleted based on the "Keep note history for (days)" setting (if the resource's "last_seen_time" is more than that number of days ago).

From local tests (inspecting the value of revisionService.ttlDays), this seems to be the case even when note history is disabled and have a minimum value of 1 day.

The task that deletes unlinked resources should run 30 seconds after startup, then every 4 hours. When it runs, ResourceService::deleteOrphanResources followed by the IDs of the deleted resources should be added to the log.

In short:

Changing the "Keep note history for" setting should change how long unlinked resources are kept (regardless of whether note history is enabled or not).

For example, changing "Keep note history for" to "1", then restarting Joplin (closing with File > Quit) and waiting 30 seconds should delete unlinked resources that were last linked more than a day ago.


Try the "Check for unused resources" feature of the joplin-batch-web site. It checks your notes for all unused attachment resources and lists them. You can then download or remove individual resources or delete all resources.

1 Like

Thanks, this looks interesting. The main reason why I began the cleaning process was that I had large textbooks stored in each course notebook that wouldn't sync, and after I deleted them, they still prompted Joplin to say “some resources couldn't be synced due to size.” I found this strange since I self-host the Joplin Server and I allow ~1Gb per file upload and I have no restrictions set on my web-server.

This post indicates that the server has a 250MB hard limit to prevent the Postgres driver from crashing the server.

1 Like

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