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:
Why won't my resource folder reduce close to the size of my back-up (simple back up plugin)?;
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.
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.
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.