How to clean spurious files on server?

Joplin 1.0.233 on macOS catalina 10.15.6 syncing against WebDAV

After migrating hundreds of notes in several turns and starting over several times things look nice on the Joplin clients, but on the server remain hundreds of spurious files that stem from the first turns of migration and had been removed in the clients already.

So my target here is to:

How to remove spurious files on the server that are not used in the clients any more?

At first I set all clients to not use a notes history, so that old versions would need to be kept on the server.

Then I synced all clients until no changes were synced any more.

Looking back on the server still turns up all those spurious files.

Is the a way to clean out the server without disconnecting all clients from the server, removing all files manually and then reconnecting all clients to server?

Thanks for your time!

Not that I am aware of and if you use the method you describe I believe that it is possible that when you reconnect all your clients the notes will be deleted from them as well, as the sync target is now empty. The fail-safe may prevent this (Options > Synchronisation > Show advanced settings) but I am not sure that Joplin will let you push the notes back to the sync target. It could be that it just prevents deletion so you can export all your notes. I have never tested this.

If you search this forum you will see many posts about deleting "orphaned" files from the server and / or the local clients. You will also see that it seems that Joplin should actually clear this out automatically after a note / resource has been orphaned for a set period of time (a period I cannot recall). From what I can gather Joplin could be a bit more efficient with this but you may find that they start to clear themselves.

I can think of two slightly different ways to clean out the sync target however both are far more extreme than your idea and involve deleting either eveything or very nearly everything.

Both methods can be a bit stressful for the user if they are not that confident on setting up Joplin and getting everything working again.

How about this process:

  1. export all notes as JEX from designated client
  2. delete all notes from designated client
  3. sync designated client, then sync all other clients
  4. disconnect sync target from all clients
  5. remove all files from sync target
  6. connect sync target to all clients
  7. import JEX archive to designated client
  8. sync designated client to target, then sync all other clients

That’s the sort of thing.

This is the one I have used where you basically delete everything and start over again. I have padded out the descriptions a bit for any who happen across this post in the future.

  1. On a desktop client export all notes / resources as a single JEX export file (File > Export > JEX - Joplin Export File). After this do not add or edit any notes - an obvious point but worth mentioning
  2. Save any custom templates or CSS files you have as they are not included in the JEX export
  3. Save copies of these files (including the JEX file) in a couple of locations “just in case”
  4. Completely shut down all Joplin clients (File > Quit)
  5. Delete the .config/joplin-desktop folder on all clients (flush data / cache on mobile apps)
  6. Go to the server / sync target and delete anything in the folder making sure not to delete the folder itself
  7. Start up a desktop client which will now be “as new”
  8. Set Joplin up as required, adding the sync settings and let it sync the default notes
  9. If using E2EE, set it up now before importing any notes (I have found it far quicker to get E2EE setup correctly before restoring all the notes rather than after)
  10. Set up the Joplin clients on the other devices and allow them to sync the default notes.
  11. If using E2EE, wait for the encryption key prompt on the other clients and enter the shared key
  12. Check that all is working OK
  13. Fully shut down (File > Quit) all clients apart from the one on the computer that has the JEX file for importing (I prefer the importing client to finish the first full sync without other clients simultaneously trying to pull down files from the server (also see below))
  14. On the desktop client that has the JEX file, delete the default notes, sync and then import the JEX file back in
  15. Sync the import desktop client to the server / sync target and allow it time to complete
  16. Start the other clients and let them sync as well (if you have a lower power server like a Raspberry Pi you may wish to do this consecutively rather than concurrently as it may stress the CPU and IO being hit by many clients downloading everything all at once)

The benefits are that this also clears out any files from the previous setup in your clients’ local resources folders (they were deleted at (5) along with everything else in .config/joplin-desktop). The downside is that it involves setting up all clients from “fresh”, and if there are many notes and many clients this process could take quite a while to complete.

I would suggest that anyone only tries this if they really, really need to clean out “orphaned” data on their clients and server. This is not exactly a simple spring-cleaning exercise.

4 Likes