# Cannot restore plex database

**URL:** <https://forums.plex.tv/t/cannot-restore-plex-database/805296>\
**Category:** Plex Media Server\
**Tags:** server-linux\
**Created:** [August 20, 2022, 8:12pm UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296 "2022-08-20T20:12:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xanderland](https://avatars.discourse-cdn.com/v4/letter/x/b5ac83/32.png) [@Xanderland](https://forums.plex.tv/u/Xanderland)\
**Post date:** [August 20, 2022, 8:12pm UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/1 "2022-08-20T20:12:38Z")

</div>

Server Version#:1.28.1.6104-788f82488

I had to wipe my main media server which is running Ubuntu Server 22.04. In preparation I made a rsync copy of my boot drive. I have restored everything but my plex database. No matter what I do it doesn’t seem to help. I have copied it back over many times. I’ve made sure the permissions were correct… I’ve tried booting up plex before and after the copy. The guides say that all I need to do is move the files to the right place, but all I can assume is something didn’t get backed up. That or it had something to do with setting the privileges to 777, but I set them back to 755 before booting it up again. Any help would be appreciated

---

<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:** [August 20, 2022, 8:19pm UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/2 "2022-08-20T20:19:39Z")

</div>

No Linux user here, but  
if you make a copy of the main database file while the server is still running, you will very likely end up with a damaged copy.  
Restore one of the backups. [Restore a Database Backed Up via 'Scheduled Tasks' | Plex Support](https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/)

---

<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:** [August 20, 2022, 10:00pm UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/3 "2022-08-20T22:00:21Z")

</div>

To add to OttoKerner:

> [@Xanderland](#):
>
> That or it had something to do with setting the privileges to 777, but I set them back to 755 before booting it up again. Any help would be appreciated

Assuming the copy was done with PMS stopped,

Everything in `/var/lib/plexmediaserver` must be owned by user `plex:plex`  
Setting permissions wildly is precarious and will fail at some point.

To set ownership and permission to standard:  
(You may copy these verbatim)

1. Confirm Plex is stopped ( `sudo systemctl stop plexmediaserver`)
2. Set Ownership back to the Plex username and set file permissions to standard.

```auto
sudo bash
chown -R plex:plex /var/lib/plexmediaserver
find /var/lib/plexmediaserver -type d -exec chmod 755 {} \;
find /var/lib/plexmediaserver -type f -exec chmod 644 {} \;

```

1. You may now start Plex and hopefully it will start (if no database damage)

---

<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:** [August 21, 2022, 1:11am UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/5 "2022-08-21T01:11:28Z")

</div>

@Xanderland

I looked at your Reddit post.

Did you have your PMS installation customized in any way?

If you moved the Application Support directory, it would explain why there is nothing in /var/lib/plexmediaserver under `Library`

---

<div class="post-metadata">

**Author:** ![Xanderland](https://avatars.discourse-cdn.com/v4/letter/x/b5ac83/32.png) [@Xanderland](https://forums.plex.tv/u/Xanderland)\
**Post date:** [August 21, 2022, 11:50pm UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/6 "2022-08-21T23:50:41Z")

</div>

The reason it’s not there is because I didn’t shut down the service when I did the rsync. It skipped those files because they were being written to.

---

<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:** [August 22, 2022, 1:00am UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/7 "2022-08-22T01:00:44Z")

</div>

> [@Xanderland](#):
>
> I have restored everything but my plex database. No matter what I do it doesn’t seem to help. I have copied it back over many times. I’ve made sure the permissions were correct… I’ve tried booting up plex before and after the copy.

So what did you copy?

rsync will read an open file. I do it all the time knowing the results are indeterminate

---

<div class="post-metadata">

**Author:** ![Xanderland](https://avatars.discourse-cdn.com/v4/letter/x/b5ac83/32.png) [@Xanderland](https://forums.plex.tv/u/Xanderland)\
**Post date:** [August 22, 2022, 2:03am UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/8 "2022-08-22T02:03:56Z")

</div>

It appears that it copied everything BUT the contents of /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/ which appears to be empty

---

<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:** [August 22, 2022, 4:14am UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/9 "2022-08-22T04:14:30Z")

</div>

Let’s resolve the status of your databases.

That will determine what comes next.

I presume you have finally minimally copied `com.plexapp.plugins.library.db` and `com.plexapp.plugins.library.blobs.db` back into `"/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases"`

Confirm database status:

```auto
sudo bash
systemctl stop plexmediaserver <-- make certain but pretty sure it still is down

cd "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases"

"/usr/lib/plexmediaserver/Plex SQLite com.plexapp.plugins.library.db" 'PRAGMA integrity_check(1)'
"/usr/lib/plexmediaserver/Plex SQLite com.plexapp.plugins.library.blobs.db" 'PRAGMA integrity_check(1)'

```

If the databases are intact, each check will report “ok” as it exits.

Presuming they are, I want all the permissions set to standard

```auto
chown -R plex:plex /var/lib/plexmediaserver
find /var/lib/plexmediaserver -type d -exec chmod 755 {} \;
find /var/lib/plexmediaserver -type f -exec chmod 644 {} \;

```

With these completed and the databases OK, you can attempt to restart PMS.

Should it fail,

```auto
cd "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs"

```

Make a tar.gz of everything you see there and attach it here so I can see the damage.

Unless there is some hope here very soon, your best choice might best be to burn it all down and start over rather than fight with it.

---

<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:** [November 20, 2022, 8:50am UTC](https://forums.plex.tv/t/cannot-restore-plex-database/805296/11 "2022-11-20T08:50:50Z")

</div>

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