# Recurring database corruption on Ubuntu Server

**URL:** <https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280>\
**Category:** Plex Media Server\
**Tags:** server-linux\
**Created:** [December 4, 2021, 10:20pm UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280 "2021-12-04T22:20:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliakhter](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aliakhter](https://forums.plex.tv/u/aliakhter)\
**Post date:** [December 4, 2021, 10:20pm UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/1 "2021-12-04T22:20:16Z")

</div>

Server Version#:1.25.0.5246  
Player Version#: Web

I am running Plex media server on Ubuntu server 20.04 and the database keeps getting issues. I have tried to recover the database using the a Plex SQLite tool and tried to take a SQL dump off the database and recreating it, but these fixes don’t seem to correct the problem. The only way the works is to recover from an older backup, generally 3 to 4 days old. This is happening weekly now and I can see data disappearing from Plex on the client side as entire sections on the home page so showing up. Eventually Plex stops working and I have to recover the database from a backup.

I have not updated the database to user the new Plex agent yet.

Does anyone have any suggestion on what could be causing this?

---

<div class="post-metadata">

**Author:** ![dbirch](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dbirch](https://forums.plex.tv/u/dbirch)\
**Post date:** [December 4, 2021, 10:33pm UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/2 "2021-12-04T22:33:49Z")

</div>

Not a dev, but I my gut says you have several degrees of database corruption. (Full crash, and your “working” setup) I bet you do not have a fully clean database, and at some point when plex its doing its scheduled tasks it continues to hit that corruption and “breaks”. Its probably way too late to get a copy of the database from 7-10 days before you first noticed this. Worst case you may need to start over with a clean database.

---

<div class="post-metadata">

**Author:** ![anon5074910](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@anon5074910](https://forums.plex.tv/u/anon5074910)\
**Post date:** [December 4, 2021, 10:46pm UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/3 "2021-12-04T22:46:49Z")

</div>

I’d concur with layers of corruption. This doc might be of help [Move Viewstate/Ratings from One Install to Another | Plex Support](https://support.plex.tv/articles/201154527-move-viewstate-ratings-from-one-install-to-another)

If what you describe happened to me I’d do the following…

Export your current view status from the your current db. Once done start again with a fresh plex db and install. Add your libraries exactly the same as you currently have and once complete then import the export you took earlier from above. You’ll have need to check for matches etc…

That should at least keep your view status. Your CW will need to rebuild from scratch but that will happen over time as you watch stuff.

---

<div class="post-metadata">

**Author:** ![aliakhter](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aliakhter](https://forums.plex.tv/u/aliakhter)\
**Post date:** [December 5, 2021, 1:34am UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/4 "2021-12-05T01:34:34Z")

</div>

Thanks for the suggestions, however I would like to add some more info that may be relevant:

1. I have several backups of the plex database, going back to 10/15/2021 for Windows and as far back as 11/19/2021 on Ubuntu
2. I moved my Plex server from a Win 10 machine to Ubuntu around 10/28/2021
3. This issue seems to have started when I switched the default user for the plexmediaserver

I can import the database from the windows backup or simply re-install plex and import the veiwstate/ratings as mentioned, but how do know that will fix the problem? I have tried re-creating the database using the SQL .dump and then .read which should have fixed data corruption issues with the file, but are there other ways to fix the database issues?

---

<div class="post-metadata">

**Author:** ![dbirch](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@dbirch](https://forums.plex.tv/u/dbirch)\
**Post date:** [December 5, 2021, 3:03am UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/5 "2021-12-05T03:03:50Z")

</div>

Can you expand on point 3?

---

<div class="post-metadata">

**Author:** ![aliakhter](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aliakhter](https://forums.plex.tv/u/aliakhter)\
**Post date:** [December 5, 2021, 3:32am UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/6 "2021-12-05T03:32:36Z")

</div>

Plex on Linux runs under username “plex” by default, but I was having some issues with that, specifically being able to write to a NAS. To resolve this I changed the default user to for the plex. The method to change the default user for Plex in Linux is shown in the following link:

[https://dausruddin.com/how-to-change-plex-user-running-under-in-ubuntu/](https://dausruddin.com/how-to-change-plex-user-running-under-in-ubuntu/)

---

<div class="post-metadata">

**Author:** ![pl\_5309](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@pl\_5309](https://forums.plex.tv/u/pl_5309)\
**Post date:** [December 5, 2021, 3:55am UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/7 "2021-12-05T03:55:30Z")

</div>

Confirm that the DB is on local storage?

---

<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:** [December 5, 2021, 4:09am UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/8 "2021-12-05T04:09:17Z")

</div>

@aliakhter

That procedure is out of date.

“PLEX\_MEDIA\_SERVER\_USER” has not been used since Ubuntu 16 was introduced.

It is only valid for SYS V Linux systems (pid 1 = init)

May I suggest reviewing:

> [@Linux Tips](https://forums.plex.tv/t/linux-tips/276247):
>
> Tips & Tricks of the Linux trade. Below, you’ll find a collection of tips, tricks, and how-to’s to help make setting up, administrating, and using Plex Media Server on Linux a little easier. [Reporting problems](https://forums.plex.tv/t/linux-tips/276247/20)[Using other hard drives (Windows or Linux) with PMS](https://forums.plex.tv/t/linux-tips/276247/2)[Customizing your Plex configuration on systemd based systems](https://forums.plex.tv/t/linux-tips/276247/3)[Using other EXT4, NTFS, or other drives (internal or USB)](https://forums.plex.tv/t/linux-tips/276247/2)[Mounting CIFS + SMB network shares for Plex use](https://forums.plex.tv/t/linux-tips/276247/4)[Mounting NFS network shares for Plex use](https://forums.plex.tv/t/linux-tips/276247/5)[Moving…](https://forums.plex.tv/t/linux-tips/276247/6)

Paying attention to:

> [@Linux Tips](https://forums.plex.tv/t/linux-tips/276247/3):
>
> Customizing your Plex configuration on systemd based systems This information is intended for those systems where cat /proc/1/comm returns systemd. On systems which use Systemd (Ubuntu 16+, Fedora 26+, Centos 7+, Debian 8+,) you create this customization file which SystemD reads prior to launching PMS. This file is independent of the default configuration and service control mechanisms in /lib/systemd/system/plexmediaserver.service. Your customization override is preserved across updates, un…

As @pl_5309 asks – Confirm the Plex metadata and database (PLEX\_MEDIA\_APPLICATION\_SUPPORT\_DIR) is on local storage ?

---

<div class="post-metadata">

**Author:** ![aliakhter](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aliakhter](https://forums.plex.tv/u/aliakhter)\
**Post date:** [December 5, 2021, 6:11am UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/9 "2021-12-05T06:11:21Z")

</div>

Yes, the database is on local storage.

---

<div class="post-metadata">

**Author:** ![aliakhter](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aliakhter](https://forums.plex.tv/u/aliakhter)\
**Post date:** [December 5, 2021, 6:21am UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/10 "2021-12-05T06:21:39Z")

</div>

> [@Linux Tips](https://forums.plex.tv/t/linux-tips/276247/3):
>
> (Ubuntu 16+

I commented out the “PLEX\_MEDIA\_SERVER\_USER” change, the rest looks ok. I was only using the override for the user, nothing else like PLEX\_MEDIA\_SERVER\_APPLICATION\_SUPPORT\_DIR, therefore the database is in the default location.

---

<div class="post-metadata">

**Author:** ![aliakhter](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aliakhter](https://forums.plex.tv/u/aliakhter)\
**Post date:** [December 17, 2021, 5:20am UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/11 "2021-12-17T05:20:08Z")

</div>

I updated Plex and that seems to have solved the problem. I did have to recover the DB from a backup once, but since then I have not had any issues for about 10. I did change a few settings, I was having issues with Plex automatically scanning daily, so I switched to manually triggering scans. I also upgraded my libraries to the new agent. If I see any more issues I will remove/re-install Plex and recover from my old windows backup. I will try to update this post if that happens.

---

<div class="post-metadata">

**Author:** ![aliakhter](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aliakhter](https://forums.plex.tv/u/aliakhter)\
**Post date:** [January 22, 2022, 8:34pm UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/12 "2022-01-22T20:34:03Z")

</div>

I am pretty sure this had something to with the Plex DB having an issue with the old metadata agent. Since I upgraded my libraries to the new Plex agent it had been running flawlessly. I tested this theory by manually linking an item to its IMDB page and the DB got corrupted halting PMS within 30 mins. I restored the DB from backup and it has run flawlessly since then.

---

<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:** [April 22, 2022, 8:34pm UTC](https://forums.plex.tv/t/recurring-database-corruption-on-ubuntu-server/762280/13 "2022-04-22T20:34:59Z")

</div>

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