# Plex Databases corrupted constantly

**URL:** https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865
**Category:** Plex Media Server
**Tags:** server-freebsd
**Created:** [January 28, 2025, 9:17am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865 "2025-01-28T09:17:01Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![soba.vfr](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/soba.vfr/32/326120_2.png) [@soba.vfr](https://forums.plex.tv/u/soba.vfr)
#### Post date: [January 28, 2025, 9:17am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/1 "2025-01-28T09:17:01Z")

</div>

Server Version#: 1.41.3.9314  
Player Version#:Any

Hi Gents.

I’m just wondering if everything is fine with these databases. Every day, I have to recover one of them, two or all three, and every night, while completing scheduled tasks I got a message “Database corrupted”.  
What’s wrong with it? No errors in syslog, no disk errors (I fsck it regularly).  
Any ideas please?  
Thank you.

---

<div class="post-metadata">

### Author: ![ChristianKent](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@ChristianKent](https://forums.plex.tv/u/ChristianKent)
#### Post date: [January 28, 2025, 10:59am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/2 "2025-01-28T10:59:22Z")

</div>

Use Chuck’s DB Repair. I’m guessing whatever you think youre doing when you recover them isn’t actually bringing back the good working version. So you’re restoring broken databases is my guess. Are you deleting the -wal files when you recover from backup? Coz they’re not supposed to be there.

---

<div class="post-metadata">

### Author: ![TheLivingBubba](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/thelivingbubba/32/336226_2.png) [@TheLivingBubba](https://forums.plex.tv/u/TheLivingBubba)
#### Post date: [January 28, 2025, 11:08am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/3 "2025-01-28T11:08:22Z")

</div>

Here is the link to the repair tool mentioned:

> **[GitHub - ChuckPa/DBRepair: Database repair utility for Plex Media Server...](https://github.com/ChuckPa/DBRepair)**
>
> Database repair utility for Plex Media Server databases

> [@DBRepair development](https://forums.plex.tv/t/plexdbrepair-development/822684/530):
>
> Folks: One last update to finish the year. sunglassesDBRepair 1.10.0 Change Yes/No DB selector to a menu Do not check the candidate DBs until after making your selection It looks like this: [chuck@lizum PlexDBRepair.2005]$ sudo ./DBRepair.sh Plex Media Server Database Repair Utility (Ubuntu 22.04.5 LTS) Version v1.10.00 Select 1 - 'stop' - Stop PMS. 2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step. 3 - 'check' …

---

<div class="post-metadata">

### Author: ![soba.vfr](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/soba.vfr/32/326120_2.png) [@soba.vfr](https://forums.plex.tv/u/soba.vfr)
#### Post date: [January 28, 2025, 11:25am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/4 "2025-01-28T11:25:14Z")

</div>

Hi, Christian. Thank you for reply.  
I don’t recover from backup, I use this recommendation every time:  
[https://support.plex.tv/articles/repair-a-corrupted-database/](https://support.plex.tv/articles/repair-a-corrupted-database/)  
The recovering itself and followed tests finishes with “ok”

Looks like it’s scheduled tasks it selves what are breaking databases during the so-called “maintenance”…

---

<div class="post-metadata">

### Author: ![soba.vfr](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/soba.vfr/32/326120_2.png) [@soba.vfr](https://forums.plex.tv/u/soba.vfr)
#### Post date: [January 30, 2025, 7:00am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/5 "2025-01-30T07:00:41Z")

</div>

Switched off all scheduled tasks and nor “corrupted databases”, nor “(Plex Media Scanner), jid 0, uid 972: exited on signal 11” in syslog… As they say, that’s what had to be proven. Anybody know what exactly do these “scheduled tasks”? What does mean, for example, “_Optimize_ database every week”, “Upgrade media analysis during maintenance” and so on?

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [January 30, 2025, 7:21am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/6 "2025-01-30T07:21:02Z")

</div>

scheduled tasks are those tasked PMS runs at night (default is 02 → 05 am)

Database optimization is a simple sqlite VACUUM command to compact it.

Upgrading media analysis means that it will look for newly added media and reanalyze anything not scanned in a while (if media changed).

I usually turn that off. My media is static (don’t change after loading)  
I usually turn off most of the other things.

These work well for me. Plus, my machine is on a UPS to prevent power issues from corrupting the DB.

 ![Screenshot from 2025-01-30 02-19-29](https://global.discourse-cdn.com/plex/original/4X/a/6/4/a640641e6dcc9b9d3b384f1db8552dffe52e4650.png)

I can’t speak to freebsd nor do I know if my script tool works there.

---

<div class="post-metadata">

### Author: ![soba.vfr](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/soba.vfr/32/326120_2.png) [@soba.vfr](https://forums.plex.tv/u/soba.vfr)
#### Post date: [January 30, 2025, 8:40am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/7 "2025-01-30T08:40:54Z")

</div>

I ‘PRAGMA integrity\_check’, ‘VACUUM’ and ‘REINDEX’ databases using cron every night. And I don’t understand why Plex Scanner started by Scheduled Tasks every time crashes (Just a few minutes later 2 am). Everything is fine when I start it manually.

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [February 19, 2025, 1:24am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/9 "2025-02-19T01:24:00Z")

</div>

@christian_kent_drools

Cool work on the HostConfig.  
I’d recommend you further refine that to ensure the host is BSD  
– Is there a default location for AppSuppDir or a common place to find it?

Please remember, there are limits to what the tool can fix.  
Its primary purpose is to fix malformed DB files (the physical DB is damaged).  
It cannot fix content errors (failed migrations, etc)

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [February 22, 2025, 7:25am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/11 "2025-02-22T07:25:49Z")

</div>

Look in your databases folder where the DB’s are.

Are there any old backups (or do you have saved backups somewhere) ?

When the data in the records is corrupted, there’s nothing which can be done except :

1. Stop PMS
2. Delete the WAL and SHM files (do they don’t corrupt the new DB you’ll use)
3. Now copy the backup DB to take the place (copy over) the damaged on.
4. Start PMS

---

<div class="post-metadata">

### Author: ![pshanew](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/pshanew/32/160555_2.png) [@pshanew](https://forums.plex.tv/u/pshanew)
#### Post date: [February 23, 2025, 2:27am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/13 "2025-02-23T02:27:39Z")

</div>

> [@christian\_kent\_drools](#):
>
> I run nightly backups of the database folder, so I have backup databases, but they are all exhibiting the same corrupt behavior when trying to do a plex upgrade.

When you run your nightly backups, do you stop Plex Media Server first, then perform the backup, and then restart PMS? I ask because attempting to restore from a database backed up without doing so can lead to corruption (for at least a couple of reasons).

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [February 23, 2025, 3:19am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/15 "2025-02-23T03:19:07Z")

</div>

There is no documentation about the DB.

Even with my knowledge and access, it’s too complex for me to fully understand all the relationships. Only the engineering team really knows all the details.

I can offer you my DB tool which helps keep what you have in the best possible form. It cleans out deleted records and will optimize the DB as well as rebuild indexes,

You’re welcome to read the documentation I have for it and use it if you want.

In general, folks usually find that:

1. Auto optimization works the best for most cases
2. Pruning & purging old temp files from PMS helps manage the fileystem bloat.
3. Should you need to restore a DB from one of Plex’s backups, it ensures that the incoming DB isn’t corrupted (at the DB level) and manages PMS to ensure you don’t get a bad DB during the restore process (Process control)

> **[GitHub - ChuckPa/PlexDBRepair: Database repair utility for Plex Media Server...](https://github.com/ChuckPa/PlexDBRepair)**
>
> Database repair utility for Plex Media Server databases

---

<div class="post-metadata">

### Author: ![ChristianKent](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@ChristianKent](https://forums.plex.tv/u/ChristianKent)
#### Post date: [February 23, 2025, 5:49am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/16 "2025-02-23T05:49:40Z")

</div>

> [@pshanew](#):
>
> When you run your nightly backups, do you stop Plex Media Server first, then perform the backup, and then restart PMS?

> [@christian\_kent\_drools](#):
>
> I do not. That was never mentioned in the docs.

lol I knew it. Like I said you’re restoring broken databases. That was my first comment.

If, at some point, you restored from your “nightly” backup (that is essentially a borked database), then all your backups thereafter are also borked.

---

<div class="post-metadata">

### Author: ![ChristianKent](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@ChristianKent](https://forums.plex.tv/u/ChristianKent)
#### Post date: [February 23, 2025, 7:56am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/18 "2025-02-23T07:56:17Z")

</div>

You want a solution to fix your problem? There isn’t any. Your problem is that you don’t understand what everyone is telling you. There’s no way to fix the content now that it’s in that state. The guy who wrote the DB Repair script just told you that even he can’t fix that. If his script can’t fix your database, it means you gotta start from scratch.

**You can’t just copy an active database.**

---

<div class="post-metadata">

### Author: ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)
#### Post date: [February 23, 2025, 8:04am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/19 "2025-02-23T08:04:17Z")

</div>

> [@christian\_kent\_drools](#):
>
> as it always seems to barf in the same place `running forward migration 202309200915`.

The Database contents are corrupt (Damaged)

My tool can only fix the SQLite database structure.  
It is a shell script. It can’t interpret the contents of each record, or a set of records, in a database and figure out what’s wrong  
(My tool is 2,362 lines line compared to the 400,000+ lines of code in PMS)

This really is one of those situations where you have to start over.

WITH THAT SAID – If you have cloud sync enabled to retain your watch history, when you do start over, PMS will retrieve your watch history for your media.

For future planning.

1. Put custom posters you want to use in with the media (and enable the “Local Media Assets” agent)
2. Stop the DB before backups or any other database operations  
– ONLY PMS can backup its database while running BECAUSE it owns the DB **AND** it locks the DB while making the backup so that no records can be changed.

---

<div class="post-metadata">

### Author: ![ChristianKent](https://avatars.discourse-cdn.com/v4/letter/c/f17d59/32.png) [@ChristianKent](https://forums.plex.tv/u/ChristianKent)
#### Post date: [February 23, 2025, 4:23pm UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/22 "2025-02-23T16:23:02Z")

</div>

> [@christian\_kent\_drools](#):
>
> If you noticed, I do have “pure” backups of the db that were created by plex, but those have migration errors that weren’t caught in time, because plex only keeps three database backups in the plexdata folder.

I told you, what Plex is backing up is a **corrupted database.** This is why despite your pronunciations that you know about databases, I don’t believe it. This logic is so basic. It feels like I’m talking to a child. **Read what I said before:**

> [@ChristianKent](#):
>
> If, at some point, you restored from your “nightly” backup (that is essentially a borked database), **then all your backups thereafter are also borked.**

I’m trying to help you, but since my help doesn’t fix your problem, you think that I’m not trying to help you. Very well, wallow in your own misery. Have fun.

---

<div class="post-metadata">

### Author: ![christian\_kent\_drools](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christian\_kent\_drools](https://forums.plex.tv/u/christian_kent_drools)
#### Post date: [May 13, 2025, 3:36am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/23 "2025-05-13T03:36:26Z")

</div>

Thanks, Chuck

At least you were helpful, unlike someone else on this forum 🙂

---

<div class="post-metadata">

### Author: ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)
#### Post date: [August 11, 2025, 3:36am UTC](https://forums.plex.tv/t/plex-databases-corrupted-constantly/903865/24 "2025-08-11T03:36:33Z")

</div>

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