Mac Music library reverted to old version after laptop crash and restart

environment:

  • MacBook Air 2022 24GB/2TB
  • Mac OS 14.4.1
  • Music v 1.4.4.48
  • No subscriptions to Apple Music or Apple Match.


Some time in mid-April, I restored a music library from a Time Machine backup and began using it. Over the last month and a half the changes have been extensive.


Last night (May 24) I closed the lid to my laptop, and when I opened it this morning, I got the message that my Mac restarted unexpectedly.


When I opened the Music app, all the changes I had made since I restored the library were gone. Deleted songs, playlists, and groupings re-appeared, and all the songs, playlists, and groupings that I had added since then were gone.


In the folder ~/Music/Previous Libraries/ there was a file "Music Library [2024-05-24 7.59.58].musiclibrary". I thought, great, I can just hold down the option key and choose that file and I will get back most of the changes I had made. No luck -- that file also had the same songs, playlists, and groupings as the originally restored library from April, with none of the changes that I had made since then.


When I right-click on either the original music library or the "Music Library [2024-05-24 7.59.58].musiclibrary" and choose "Show Package Contents", there are over 2,800 temp files that are about 22 MB each, and almost 5,000 temp files ranging in size from 2 - 25 KB. As a result, the library files are each over 64 GB in size.


Also, the date modified of "Library.musicdb" within either package is Aug 23, 2022.


So, some questions (in order of importance to me):


  1. Is there a way to "restore" the changes made through last night? (I do not have any Time Machine backups since I started this process.)
  2. Is there a way to make the Music app "save" changes to the library so that this doesn't happen again?
  3. What generates those temp files and what are they?
  4. Why is Music storing so many of them?
  5. Apart from choosing "Show Package Contents" and manually deleting the temp files, how do I get the Music app to delete them and have a reasonably sized library file?


Thanks in advance for any help.

Posted on May 24, 2024 7:09 AM

Reply
3 replies

May 24, 2024 7:55 AM in response to ChroamDoam

See Empty/corrupt iTunes/Music library after upgrade/crash - Apple Community. One of those .tmp files might be the last good version of your recent library. The fact that you have more than one or two is a hint that something is going wrong on a regular basis. Do you have any third party security software? If so add an exclusion for the Music folder. The .tmp files are generated as the library is updated, a new file is written out, the original deleted, and the tmp file renamed to take its place. Anything that interferes with that process can lead to a .tmp file not being removed and/or loss of recent changes. As a rule there will be no .tmp files, but there is no built in scavenging task to delete them, you need to do that by hand.


tt2

May 24, 2024 9:49 AM in response to turingtest2

Hi, thanks for your reply.

Do you have any third party security software? ... The .tmp files are generated as the library is updated, a new file is written out, the original deleted, and the tmp file renamed to take its place.

I have no third-party security or anti-virus software, nor have I ever installed such software. Any other ideas why the process you described is not happening?


One of those .tmp files might be the last good version of your recent library.

Bingo. I was going to ask you how to determine this and how use them to restore my library... but I figured it out, and in case anyone else runs into this problem. Here is what I did:


  1. Quit Music app.
  2. Made a backup on an external drive of "Music Library.musiclibrary" (in case anything went wrong, and on an external drive because the Mac OS does not actually create a physically different file when you make a copy of a file on the same drive under APFS).
  3. Right-clicked on "Music Library.musiclibrary" (the library in use) and chose "Show Package Contents".
  4. Renamed "Library.musicdb" to "Library-orig.musicdb" and "Library Preferences.musicdb" to "Library Preferences-orig.musicdb"
  5. Located the most recent .tmp files
  6. Renamed "Temp File 7838.tmp" to "Library.musicdb" (I chose that one because they were both 22.4 MB in size)
  7. Renamed "Temp File 7839.tmp" to "Library Preferences.musicdb" (they were both 2K in size)
  8. Deleted "Library-orig.musicdb" and "Library Preferences-orig.musicdb"


When I launch the Music app, the library now reflects all the changes I had made through last night. Thanks for your help!

Mac Music library reverted to old version after laptop crash and restart

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.