I'm trying another variant. This may be completely stupid but I'm running out of things to do.
I've imported my JEX backup into a completely clean Joplin Mac.
I mounted the NextCloud volume directly so I can copy files as if on the same network. I am waiting for a local sync to this directly connected volume. I've used Advanced -> push all local files to sync target.
After it has completed, I'll change the way the sync happens. I'll switch to WebDAV sync method. I hope then Joplin will check the files and see that they are identical and won't get stuck on the upload.