Server Version#: 1.22.3.4523 (Unraid Docker, PMS official)
Player Version#: 1.31.1.2262-74fdc6b7
So I’ll just get this out of the way first: unclean shutdown due to power failure, db correuption, no backups (only the blobs were backing, since apparently the main db has had corruption for a while I was unaware of, and seems the db won’t backup if there’s any corruption), and I’ve made sure my array is properly setup now going forward with my Plex config folder (appdata) is being backed up.
Spent the past few days reading every post on the Plex forums and Reddit I could Google, but still can’t repair my db.
I’ve tried the db repair procedure now on both the native terminal (Unraid/Linux), and copied over to my Windows desktop, and keep getting the same errors:
sqlite3 com.plexapp.plugins.library.db "DROP index 'index_title_sort_naturalsort'"
Error: no such index: index_title_sort_naturalsort
sqlite3 com.plexapp.plugins.library.db "DELETE from schema_migrations where version='20180501000000'"
Error: no such table: schema_migrations
sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check"
Error: no such collation sequence: icu_root
sqlite3 com.plexapp.plugins.library.db .dump > dump.sql
sqlite3 com.plexapp.plugins.library.db < dump.sql
Error: near line 1073618: no such collation sequence: icu_root
I’ve even tried opening dump.sql in SQL management studio, and deleting schema_migrations version 20180501000000 manually, and also found references to index_title_sort_naturalsort and index_title_sort_icu , but don’t really know what I’m looking at.
What’s weird is that Plex still runs seemingly fine, with the only symptom of weirdness being that TV Shows don’t show up on the home screen at all.
Anyone have any further tips or tricks to hopefully salvage my db? The main reason I don’t want to start over is mainly because I don’t want to re-invite my family member’s and friends and set up their permissions again. Outside of that I would have just cut my losses and started fresh.
You need to use /usr/lib/plexmediaserver/Plex\ Media\ Server --sqlite on Linux.
This will invoke the sqlite shell which is built into PMS and give you the additional plug-ins for sqlite.
Thank you for the reply. I’m trying to figure out how I can stop my PMS service on the Docker. It keeps auto-restarting when I kill the proc. Could I just spin up a server on my Windows desktop, then use sqlite?
Btw, I’m on my Windows desktop when running sqlite3
Finally think I’m doing it correctly now that I figured out how to stop Plex within the container. However, still not working out. Importing dump.sql results in a 0kb file, and no error on the console:
# ./plex_service.sh -d
# cd "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/"
# cp com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original
# "/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "DROP index 'index_title_sort_naturalsort'"
Error: no such index: index_title_sort_naturalsort
# "/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "DELETE from schema_migrations where version='20180501000000'"
# "/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "PRAGMA integrity_check"
*** in database main ***
On tree page 270300 cell 11: 2nd reference to page 321059
Error: database disk image is malformed
# "/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "DROP index 'index_title_sort_naturalsort'"
Error: no such index: index_title_sort_naturalsort
# "/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "DELETE from schema_migrations where version='20180501000000'"
# "/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db .dump > dump.sql
# rm -rf com.plexapp.plugins.library.db
# "/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db < dump.sql
# ls -l
total 2056568
drwxr-xr-x 1 root root 352 May 17 13:33 backups
-rw-r--r-- 1 root root 305267712 May 16 22:13 com.plexapp.plugins.library.blobs.db
-rw-r--r-- 1 plex users 283509760 May 6 02:03 com.plexapp.plugins.library.blobs.db-2021-05-06
-rw-r--r-- 1 plex users 283016192 May 9 02:04 com.plexapp.plugins.library.blobs.db-2021-05-09
-rw-r--r-- 1 plex users 285820928 May 12 02:04 com.plexapp.plugins.library.blobs.db-2021-05-12
-rw-r--r-- 1 plex users 304721920 May 15 02:03 com.plexapp.plugins.library.blobs.db-2021-05-15
-rw-r--r-- 1 root root 0 May 17 13:30 com.plexapp.plugins.library.db
-rw-r--r-- 1 root root 346404864 May 17 13:22 com.plexapp.plugins.library.db.original
-rw-r--r-- 1 root root 297172087 May 17 13:29 dump.sql
To note, this isn’t documented here or anywhere else that I can find. I’d assume this should / would need to be mentioned or added to this article: Repair a Corrupt Database | Plex Support
I’ve been having the same issues running Plex in a Docker container so can’t access the sqllite shell with the right plugins without using a separate machine / non docker Plex install.
It’s been 18 days since this was opened, and even longer since the commands in those instructions stopped working.
Why is the official documentation still not corrected? It’s insane that searching for instructions to repair a corrupt database yields a real doc page with instructions that do not work, and you have to then google some random arcane error message to find a random forum thread to figure out how to fix it.
There are no backups for the main database, only the blobs.db. I was able to repair it after finding this post with the specific magical incantation to open a sqlite CLI with Plex’s extensions loaded, but FFS, fix the documentation. It’s been weeks. How is having broken documentation considered acceptable?
In any docker container for Plex I’ve ever used (linux based) there are folders, for plex, stored outside of the container - the DB files are part of what’s stored outside of the container