What to restore? I have a corrupted Plex Library

Server Version#: 1.21.1.3830
Ubuntu 20.04

Many on my hard drive in the plex home dir are corrupted, and some are not. What’s the minimum set of directories I need to reconstruct the server? All the media is fine, but I don’t want to lose all the matching and rating I have done. Most importantly, I think the com.plexapp.plugins.library.db is OK.

Any suggestions? I was hoping a fresh install, stop the service, move a few critical files into place, start the service, and get most of what I had. It’s OK if art and supporting data is downloaded again.

Thanks in advance.

At bare minimum.

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

If the databases are corrupt then you must start over.

Thanks! So I can just stop the service, copy the databases dir into the right location, then start the service again?

Yes.

If you also have Preferences.xml (the identity) then you’re in the best position possible.

OK! Looks like some success. Fresh install, stop service, copy files, start service, web page looks OK. No images, but that’s OK for now. I assume I need to refresh all metadata.

After a few seconds, however, plexmediaservice crashed on the server. I have the .dmp file if anyone cares. The service then automatically restarted and seem to be up.

Many thanks for the help. I know now what I need to make sure I have on- and off-site backups of.

I will need the logs first as the crash will have also been reported there.
I suspect the crash is because it got caught in an unexpected state doing this disaster recover

I have a cron job to make a tar ball.

sudo bash
systemctl stop plexmediaserver
tar cf /path/to/backup/location/PlexBackup.tar  ./Library
systemctl start plexmediaserver

Embellish as appropriate

er, the entire Plex Library dir is 5GB. you want all that? The space is used by the many back ups in the Databases dir

du -hs ./*
68K	./com.plexapp.dlna.db
32K	./com.plexapp.dlna.db-shm
288K	./com.plexapp.dlna.db-wal
23M	./com.plexapp.plugins.itunes.db
32K	./com.plexapp.plugins.itunes.db-shm
0	./com.plexapp.plugins.itunes.db-wal
465M	./com.plexapp.plugins.library.blobs.db
581M	./com.plexapp.plugins.library.blobs.db-2020-12-16
536M	./com.plexapp.plugins.library.blobs.db-2020-12-22
461M	./com.plexapp.plugins.library.blobs.db-2020-12-25
462M	./com.plexapp.plugins.library.blobs.db-2020-12-28
286M	./com.plexapp.plugins.library.db
308M	./com.plexapp.plugins.library.db-2020-12-16
301M	./com.plexapp.plugins.library.db-2020-12-22
282M	./com.plexapp.plugins.library.db-2020-12-25
284M	./com.plexapp.plugins.library.db-2020-12-28
257M	./com.plexapp.plugins.library.db.original
223M	./com.plexapp.plugins.trakttv.db
32K	./com.plexapp.plugins.trakttv.db-shm
1.4M	./com.plexapp.plugins.trakttv.db-wal
225M	./dump.sql
0	./sqlite3
11M	./tv.plex.providers.epg.cloud-48e3c474-c8de-455e-ac99-24b0baca47ec.db
32K	./tv.plex.providers.epg.cloud-48e3c474-c8de-455e-ac99-24b0baca47ec.db-shm
656K	./tv.plex.providers.epg.cloud-48e3c474-c8de-455e-ac99-24b0baca47ec.db-wal

you can clearly take out dump.sql unless you want that as a disaster mode form (not a bad idea when gzipped)

the older backups can go but I would keep at least 1 handy for immediate recovery if needed.

5 GB isn’t bad. Try this one :wink:

[~] # cd /share/CA*/.qpkg/Ple*
[/share/CACHEDEV3_DATA/.qpkg/PlexMediaServer] # du -ms Library
87413	Library
[/share/CACHEDEV3_DATA/.qpkg/PlexMediaServer] # 

When the Library was fully populated, it was 450GB.

I’m a little confused. Do you want me to send you the Library? I can remove the backups and the dump, that will make it more reasonable. How should I get the file to you?

No. please do not send me anything . There’s no point in that.

I was discussing this with my teammate. With Preferences.xml and com.plexapp.plugins.library.db, you can regenerate everything.

We were discussing it because of the packaging rewrite I’m doing on Synology (their new DSM 7 OS version)

Ok, thanks. I’m back up and running, and i have a decent back up for just the important files:
Here’s my back-up section from my daily backup script. Note, I moved my Plex dir from my system drive to another location, so the paths will not work for anyone else, but people will get the idea. I’m sure I could be more efficient with the source paths, but I’m lazy sometimes :slight_smile:

systemctl stop plexmediaserver
TARGET=/media/data/backups/plex-core.tz
tar -czvf $TARGET /media/data/plexdir/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/*.db /media/data/plexdir/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/*.db-shm /media/data/plexdir/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/*.db-wal /media/data/plexdir/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml
chown allan:allan $TARGET
systemctl start plexmediaserver

FYI:

-shm and -wal files are not needed. They are part of the runtime (when open) operation of SQLite.

When PMS shuts down cleanly, those files are folded into the DB by Sqlite .

I knew that about the shm and wal files, but I figure better safe than sorry. Thanks for all your help. So technically, this is all that’s needed for a a simple backup. I plan on doing this backup nightly.

systemctl stop plexmediaserver
TARGET=/media/data/backups/plex-core.tz
tar -czvf $TARGET /media/data/plexdir/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/*.db  /media/data/plexdir/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml
chown allan:allan $TARGET
systemctl start plexmediaserver

I’m researching but you probably want to also include the certificate cache.
This is because the certificate data is stored in the DB now (a recent change).

You 'll find the cert data files in Plex Media Server/Cache

-rw-rw-rw-   1 admin administrators 1848 2020-11-06 09:11 ca.crt
-rw-rw-rw-   1 admin administrators 3222 2020-11-06 09:11 certificate.p12
-rw-r--r--   1 admin administrators 5232 2021-01-09 14:48 CloudAccessV2.dat
-rw-r--r--   1 admin administrators 9184 2021-01-09 05:09 CloudAccountV2.dat
-rw-r--r--   1 admin administrators  848 2021-01-09 14:48 CloudUsersSubscriptionsV2.dat
-rw-r--r--   1 admin administrators  512 2021-01-09 14:48 CloudUsersV2.dat
-rw-r--r--   1 admin administrators 9760 2021-01-09 05:09 Flags.dat

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