# Corrupt Database

**URL:** <https://forums.plex.tv/t/corrupt-database/692490>\
**Category:** Plex Media Server\
**Tags:** server-windows\
**Created:** [February 19, 2021, 4:08pm UTC](https://forums.plex.tv/t/corrupt-database/692490 "2021-02-19T16:08:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 4:08pm UTC](https://forums.plex.tv/t/corrupt-database/692490/1 "2021-02-19T16:08:46Z")

</div>

Server Version#: 1.21.3.4046-3c1c83ba4  
Player Version#: N/A

Good Morning Everyone,

This morning I work to an error message saying the database was corrupt. I have followed other articles and not having much luck. My database is about 700MBs so it is something I have been using for a long time. I have attempted a restore of the Database Directory, and repairing the database with sqlite3. I really want to repair this database because I need the watched / unwatched but most importantly I have all my playlists. Really don’t want to recreated all my Star Wars or Marvel playlist if I don’t need to.

Thanks,  
Mike aka Stretch

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [February 19, 2021, 4:31pm UTC](https://forums.plex.tv/t/corrupt-database/692490/2 "2021-02-19T16:31:20Z")

</div>

> **[Restore a Database Backed Up via 'Scheduled Tasks' | Plex Support](https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/)**
>
> One of the many Scheduled Tasks that a Plex Media Server performs is to make regular backups of the core...

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 4:55pm UTC](https://forums.plex.tv/t/corrupt-database/692490/3 "2021-02-19T16:55:40Z")

</div>

Thank you for the reply and I thought that would work. Under normal circumstances it would have be I see that I change the default destination to a NAS and upon trying to get that backup I found I had 2 drives that went out in that NAS. ☹ I do have the original files that were saying they were corrupted. I also restored those files to a couple days ago and having the same problem. I realize I might be SOL now that I found the NAS has gone out but hoping there is another way.

Thank you again,  
Mike aka Stretch

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [February 19, 2021, 5:00pm UTC](https://forums.plex.tv/t/corrupt-database/692490/4 "2021-02-19T17:00:09Z")

</div>

> [@stretcher](#):
>
> I have attempted … repairing the database with sqlite3.

What was the outcome of that repair attempt?

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 5:08pm UTC](https://forums.plex.tv/t/corrupt-database/692490/5 "2021-02-19T17:08:20Z")

</div>

I used this article when doing it.

> **[Repair a Corrupt Database | Plex Support](https://support.plex.tv/articles/201100678-repair-a-corrupt-database/?_ga=2.180050595.685119928.1613746919-1441369747.1613746919)**
>
> Though rare, it is possible for your main Plex Media Server database to become corrupted. For instance, it might happen...

When checking for Corruption or Repair I get the following message.

Error: database disk image is malformed

Hope this helps and Thanks

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [February 19, 2021, 5:09pm UTC](https://forums.plex.tv/t/corrupt-database/692490/6 "2021-02-19T17:09:47Z")

</div>

> [@stretcher](#):
>
> When checking for Corruption or Repair I get the following message.
> 
> Error: database disk image is malformed

Did you only do the check or did you start the actual repair process?

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 5:10pm UTC](https://forums.plex.tv/t/corrupt-database/692490/7 "2021-02-19T17:10:29Z")

</div>

I also found an article with MovieFan.Plex posted.

> [@Corrupt database](https://forums.plex.tv/t/corrupt-database/95478/6):
>
> Ok, just making sure. How big is the library? Would it be a huge undertaking to delete the .db file and rebuild rather than attempt to repair?

But I get the same error as I do from running repair or checking for corruption.

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 5:11pm UTC](https://forums.plex.tv/t/corrupt-database/692490/8 "2021-02-19T17:11:17Z")

</div>

I tried both Repair and check for Corruption.

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [February 19, 2021, 5:12pm UTC](https://forums.plex.tv/t/corrupt-database/692490/9 "2021-02-19T17:12:21Z")

</div>

At which step of the repair process do you encounter the error?

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [February 19, 2021, 5:21pm UTC](https://forums.plex.tv/t/corrupt-database/692490/10 "2021-02-19T17:21:39Z")

</div>

Try with a slightly modified step 4:

```auto
sqlite3 com.plexapp.plugins.library.db .recover > dump.sql

```

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 5:22pm UTC](https://forums.plex.tv/t/corrupt-database/692490/11 "2021-02-19T17:22:12Z")

</div>

Every step has outside of doing a backup, restore or copy on the files has encountered that error.

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [February 19, 2021, 5:25pm UTC](https://forums.plex.tv/t/corrupt-database/692490/12 "2021-02-19T17:25:03Z")

</div>

When you try the above alternative command line, does it abort immediately with the error message, or do you get a `dump.sql` file out of it? And if you do, how large is it?

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 5:27pm UTC](https://forums.plex.tv/t/corrupt-database/692490/13 "2021-02-19T17:27:24Z")

</div>

Currently it is running and not erroring. I am going to let it finish and will update the post.

Thanks,

Mike aka Stretch

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 5:50pm UTC](https://forums.plex.tv/t/corrupt-database/692490/14 "2021-02-19T17:50:26Z")

</div>

I could be just impatient and if so just let me know. How long should I keep this running?

Thanks,  
Mike aka Stretch

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [February 19, 2021, 5:53pm UTC](https://forums.plex.tv/t/corrupt-database/692490/15 "2021-02-19T17:53:14Z")

</div>

It depends on the size of your database and probably also the extent of the damage.  
The speed of your server is of course also important.

On my old Core i7 desktop machine, I can export and re-import a 350 MB database (no damage, though) within very few minutes.

There is no guarantee that th eprocedure will be successful. If the damage is too big, you may end up with lots of duplicate or wrong data in the dump file.

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 5:54pm UTC](https://forums.plex.tv/t/corrupt-database/692490/16 "2021-02-19T17:54:25Z")

</div>

Okay I will give it more time. Running on my Server at home Dual Xeon 2.4GHz 32GB Memory but my Database was pretty big.

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 6:06pm UTC](https://forums.plex.tv/t/corrupt-database/692490/17 "2021-02-19T18:06:13Z")

</div>

Alright so I let it finish and the dump.sql is 183,695KB big. When I try to open Plex I get the following message

Corrupt database  
Plex Media Server was unable to open its media database.

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [February 19, 2021, 6:08pm UTC](https://forums.plex.tv/t/corrupt-database/692490/18 "2021-02-19T18:08:02Z")

</div>

The above is only step 4.  
Did you execute steps 5 and 6?

---

<div class="post-metadata">

**Author:** ![stretcher](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@stretcher](https://forums.plex.tv/u/stretcher)\
**Post date:** [February 19, 2021, 6:14pm UTC](https://forums.plex.tv/t/corrupt-database/692490/19 "2021-02-19T18:14:06Z")

</div>

I was waiting to make sure I did what you were wanting. I went ahead and ran 5 then 6. I have attached what I get when it runs. It is long and wouldn’t let me put in message.

[https://www.reliasystech.com/plex\_errors.txt](https://www.reliasystech.com/plex_errors.txt)

Thanks

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [February 19, 2021, 6:28pm UTC](https://forums.plex.tv/t/corrupt-database/692490/20 "2021-02-19T18:28:01Z")

</div>

Looks like the damage is greater than what can be automatically repaired.  
I have a guy who said he can take a look at the file over the week end.  
I will contact you per PM.

[Next page](https://forums.plex.tv/t/corrupt-database/692490.md?page=2)
