About a year ago, my Plex container stopped working after updating to a newer image. I was able to work around the issue by pinning the container version to the last working image prior to the breaking update. Over the course of this past year, I’ve occasionally spent some time reading through forum posts, trying to upgrade to different newer versions, and doing my best to glean something useful from the generic database errors that I could find in the container logs. This week I changed up my search terms and found a solution.
The Problem
Somehow, I ended up in a state where I had a working Plex instance, but upgrading the container to a newer image would fail. Either the server would fail to start outright, or it would start with all of my libraries showing up empty. Rolling back to the older image always gave me a working instance, so it was never a particularly high priority for me to diagnose and fix the issue (tbh, I was hoping Jellyfin would address music transcoding with Android Auto and I could finally just migrate to that). Eventually, I figured out that the issue was coming from a database operation as part of a migration that happens during container init.
The Solution
Once I realized this was a database issue, I was able to find this Plex support article that discusses repairing a database. I ended up rebuilding the database using the process towards the end of that article, and then I was able to pull the latest Docker image which started right up (after running that database migration). As far as I can tell, all of my libraries, watch history, playlists, etc. are still there.
Closing Thoughts
I have no idea what happened to cause my database to become corrupted, but I believe it is the same database I started with when I was running Plex on Windows, over 10 years ago. I do wish Plex had friendlier tools for database import/export and migration; the documented process of just copying the application data isn’t particularly friendly for capturing backups and I have no idea how to work with that to efficiently scale out a Plex container for high availability.
In any case, I have Plex back up and running without any major issues 🎉. I still plan on moving to Jellyfin, but it doesn’t currently let me play my music library in my car (Android Auto only does direct playback), so I’m sticking with Plex for the time being.