Apple Music library corruption - Fix for Library reverting to old version (losing changes to music library)
Documenting this here because I can't comment in All my music disappeared. No more library… - Apple Community -- and this post gave some good clues @turingtest2 which led to a solution. I am really indebted to them for their thoughtful comments.
I searched all over the forums / reddit for weeks. It's been truly insane. I've reinstalled two macs over it, and wiped an iphone back to factory because i couldn't figure out where the issue was coming from.
I have to put some good karma back in the universe here and drop the instructions to fix this issue - I hope the mods post this, there are lots of threads out there.
So the presenting problem (this is for SEO):
Apple Music Library randomly reverts to an old version, wiping out weeks of playlists and music library editing (music library.musiclibrary). I lost all my changes to my music library.
The issue is not with iTunes Match (which I don't use) or the Apple music subscription service and icloud drive (which I don't use).
The issue is the corruption of music library.musiclibrary
The fix:
Take your music library.musiclibrary file and right click, "Show Package content"
There are probably Temp File in there (Temp files) and the "Library.musicdb" file has an older date. I had literal thousands!
Go look at the most recent Temp files that are in larger size but prior to the time you lost all your work. (Basically, if your Library.musicdb is say, 5 MB even a few weeks ago, that's about the size of your DB unless you added a bunch of things. So go find the most recent Temp file that's 'library.musicdb' sized. See screen grab for "Show package content" with corrupted files.
Now in my grab below, notice that all the non-temp files are wack, frozen on Nov 5, but Extras.itb is nov 18.
So, first, make a copy of music library.musiclibrary and save it someplace as a super backup.
Now, close the Music app. Then, grab AppCleaner and delete all the preferences for Music Library. (You delete the various caches, not the music library folders or the app)
then, take that most recent Temp file that's library.musicdb sized. Delete - every single thing - in the "Show Package Content" view of Music library -- except that big Temp file.
Go and delete your trash.
Now rename the big Temp file as library.musicdb
Yes, you are missing Applications.musicdb and all the other files in the below screen shot since you deleted everything. But they will get re-generated from your new library.musicdb when you open the Music app next. Trust and Believe.
Now go to the Music app, and press Option as you click the app to execute it. Choose library and point to the music library.musiclibrary file (that has just been cleaned up by you).
Watch as your "lost" data returns, which was in the Temp file all along. And if you "Show package content" again on music library.musiclibrary, you will see that the applications.musicdb, extra.itdb and other files we had brazenly deleted are back again - but brand new.
If you make a change now to your library in the music app. For example, add some metadata in the comment of a music file, you won't be seeing a bunch of new Temp files being created but you will see library.musicdb is getting an updated timestamp.
Music library.musiclibrary is uncorrupted!
MacBook Pro