Corrupted database - .Read cannot open

Hi !
I received a notification that my plex database was corrupted. I followed the steps explained here : https://support.plex.tv/articles/repair-a-corrupted-database/ with no success. At the last step (low-level recovery), when I do the command :

.read db-recover.sqlite

I have the following message :

Error: cannot open “db-recover.sqlite”

I confirm that I am in the right folder. I suspect that the file is too big, is that possible ? The file produced by the .recover command is 114gb (but my initial corrupted database is 40gb)…

Use DBRepair instead of the method in the Plex support article. See this post: Issue getting movies (tv shows are fine) to play on one TV and iphone - #2 by FordGuy61

Did you run any 1.41.7 releases?

You might have been bitten by the “database bloat” bug in some 1.41.7 releases.

After you run DBRepair, update to 1.41.8 (current public) if you’ve not already done so (to get off the problematic 1.41.7 releases).

The run the debloat routine.

See this post: Library.db size more than doubled in latest version - #410 by OttoKerner

Save the instructions as a .bat file (ex: deflate.bat), then run it from the command line like you did with DBRepair.

It should reduce your database file back to normal size.

I already tried DBRepair.ps1 but it produced, again, a big temporary file but could not reimport back to the database and resulted in an empty database. I will try the .bat instead as you suggests, you never know !

Oh, yes, surely I ran into the bloat bug you are talking about because I download every Plex update. I wasn’t aware of this ! I saw that the size of my backups has increased dramatically over a few days. After DBRepair, I will try the debloat routine and will post the result I get.

Thank you for your fast and great answer !

If your run out of room, move one or more of the bloated backups to another location to free up space.

If DBRepair does not work, post the output to the thread.

Also post a directory listing of the directory with the Plex database files. I’d like to see the files and their sizes.

Hi ! Thank you very much for your continued help. I have a lot of free space, that’s not a problem. To tell you a bit more info, my Plex data is on an SSD drive to be faster. I changed the Plex setting to move it away from my C drive.

The output of DBRepair.bat is this :
H:\Plex Data\Plex Media Server\Plug-in Support\Databases>DBRepair-Windows.bat

NOTE: This script is being replaced with the PowerShell script DBRepair-Windows.ps1,
which aims to better emulate DBRepair.sh (more options, interactive mode, etc).
Consider moving over to the new script.

23:20:47,08 – ====== Session begins. (2025-07-02) ======
23:20:47,40 – Performing DB cleanup tasks
Error: stepping, database disk image is malformed (11)
23:21:55,69 – Exporting Main DB
23:59:20,73 – Exporting Blobs DB
0:04:03,60 – Exporting Complete.
0:04:03,60 – Creating Main DB
2:05:01,60 – Verifying Main DB
2:05:02,61 – Main DB verification check is: ok
2:05:02,61 – Main DB verification successful.
2:05:02,61 – Creating Blobs DB
2:05:43,66 – Verifying Blobs DB
2:05:46,11 – Blobs DB verification check is: ok
2:05:46,17 – Blobs DB verification successful.
2:05:46,17 – Import and verification complete.
2:05:46,17 – Reindexing Main DB
2:05:46,21 – Reindexing Blobs DB
2:05:55,92 – Reindexing complete.
2:05:55,92 – Moving current DBs to DBTMP and making new databases active
1 fichier(s) déplacé(s).
1 fichier(s) déplacé(s).
1 fichier(s) déplacé(s).
1 fichier(s) déplacé(s).
2:05:55,93 – Database repair/rebuild/reindex completed.
2:05:55,93 – ====== Session completed. ======

So it seems to work but it produce a .db file of size 0 at the end.
When I delete this file and rename the original corrupted database, my folder looks like this :

You see that my main database is 40gb. Plex hasn’t backup my database in more than a month because it’s corrupted and I was a little slow to act because my server works fine anyway, for now.

When I executed DBRepair.ps1 it tells a bit more, there is an error when importing, but it doesn’t tell much and it produce also an empty file :
2025-06-29 10.53.54 – Session start: Host is Windows 10 (Build 26100)
2025-06-29 10.54.18 – Auto - START
2025-06-29 11.36.36 – Repair - Export databases - PASS
2025-06-29 12.49.04 – Auto - Failed to import Plex database (importing ‘H:\Plex Data\Plex Media Server\Plug-in Support\Databases\dbtmp\library.sql_2025-06-29_10.54.17’ into ‘H:\Plex Data\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db_2025-06-29_10.54.17’): Process exited with error code 1 (constraint error?), cannot continue.
2025-06-29 12.49.04 – Auto - FAIL
2025-06-29 12.49.15 – Stop - START
2025-06-29 12.49.17 – Auto - START
2025-06-29 13.29.50 – Repair - Export databases - PASS
2025-06-29 16.36.05 – Repair - Import - PASS
2025-06-29 16.36.06 – Repair - Verify main database - PASS
2025-06-29 16.36.09 – Repair - Verify blobs database - PASS
2025-06-29 16.36.10 – Reindexing Main DB
2025-06-29 16.36.10 – Reindexing Blobs DB
2025-06-29 16.36.17 – Reindexing complete.
2025-06-29 16.36.17 – Moving current DBs to DBTMP and making new databases active
2025-06-29 16.36.17 – Auto - PASS
2025-06-29 16.38.06 – Prune - START
2025-06-29 16.38.37 – Prune - Removed 6002 files over 30 days old (308.35 MiB), out of 125461 total files
2025-06-29 16.38.37 – Prune - PASS
2025-06-29 16.38.41 – Ignoring database errors.
2025-06-29 16.38.54 – Start - START
2025-06-29 16.38.55 – Start - PASS
2025-06-29 16.39.08 – Exit - Deleted temp files.
2025-06-29 16.39.08 – Session end. 06/29/2025 16:39:08

The big db-recover.sqlite file is what was created with the official Plex instructions that I talk in my initial post. I kept it in case I find how to reimport it.

Later, I will try the debloat thing you were talking about and I will post my results.

Thanks again !

The constraint error indicates it’s not a physical corruption but a logical one. You’ve got entries with the same unique identifier. The only fix is to identify the duplicate entries and remove them.

Oh wow, that’s super interesting and not self evident with the error message !! And how do I find these duplicates entries ?

Hi !

So I tried the following :
#1 : DBRepair.ps1 auto repair with activating the option to ignore errors before.
Still no changes. The script work for several hours and produce an empty file.

I reactivated my corrupted backup.

#2 : Debloat batch file. Several errors telling that the database is malformed and the script aborts.

#3 : I returned to the 114gb file produced by the Plex official instruction page and, instead of using .read to reimport it in the database, I used the same trick used by DBRepair, that is

SQLite.exe com.plexapp.plugins.library.db < db-recover.sqlite

This worked ! It produced a working database with no error messages ! Prama integrity check tells my that the database is ok. This looks good !

I retried the debloat batch file with this database and I got the same error messages telling me that the database is malformed. That’s not a good sign.

I cross my fingers and wait 3 days for Plex to try to do the backup and send me or not a notification that my database is corrupted again.

If any of you have any other ideas (how to find the duplicate ids for example), I’m all ears !

Thanks !

Plex successfully made a backup of my new database last night and I didn’t receive a notification telling me that my database was corrupted so I think that my problem is solved !

So if this helps someone, the trick was to follow the plex official instructions for corrupted database but, at the end, because the file is probably too big, instead of using .read to reimport the big file, I used

[Path]\SQLite.exe com.plexapp.plugins.library.db < db-recover.sqlite

Weirdly, DBRepair didn’t work for me.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.