Help with disaster recovery needed

Server Version#: Version 1.20.3.3437
I have two NASes, one primary the other secondary (as in primary backing up onto the secondary with Plex scanning disabled). My rsync script has been copying over all the media AND Library folder daily excluding the Preference.xml file to have Plex running on the same database on both servers.

Last week I had two events happening on my NASes.

  1. Both my plex installation lost the database settings out of the blue (no update or action what so ever from myself) giving me the message::

This library is currently empty

Expecting more? Visit the Manage Libraries page to add folders and scan library files.

  1. The very next day for a totally unrelated problem my primary NAS filesystem got corrupted (XFS issue)

Now, As part of the disaster recovery I have restored all the data from the secondary NAS onto the primary, this included copying over the plexmediaserver content. I unfortunately happen to have overwritten the Preference.xml too on the primary which wasn’t very wise I suppose.

So current situation is:

Primary NAS:

  • data fully restored (including hundreds of thousands of Plex Library files)
  • Plex in unreachable (I guess the Preference.xml does’t have the correct MachineIdentifier any more

Secondary NAS:

  • plexmediaserver Library folder appears to be full of data but Plex reports:

This library is currently empty

Expecting more? Visit the Manage Libraries page to add folders and scan library files.

So my questions are:

  • how do I reverse engineer the correct MachineIdentifier and anything else I would need to have Plex running again on the primary server
  • Given on both NASes happen to have the Library fully populated how do I re-add it onto Plex without losing all (as in having to rescan from scratch and match manually all the mistakes/not-found titles)?

Thanks!

Anybody please? How do I reimport the Library without having to have scan/refresh everything?

Ok let’s take a different approach. Where is the Library defined in the linux filesystem?
Looking for the place where plex reads when deciding where to scans for media

image

Please?

I’m sorry about the delay but for some reason the forum didn’t notify me.

First, the bad news: There is no way to reverse engineer the UUIDs.
Second, dependent on which way you installed Plex (plug-in or the debian base), we can probably bring things back by hand-crafting at the command line .

Given you have rsync in use, what can you tell me about the pathnames you’ve been syncing?

Certainly!

plex was installed via openmediavault plugin if I remember well. At the time I did create a symlink from /var/lib/plexmediaserver/ to /mnt/raid5/plexmediaserver/ so rsync has resolted the whole directory. About the full backup process you can check this thread which was very informative for me:

In the meantime I did a fresh install of plex on the primary server (nothing that could be lost any ways). I don’t mind re-adding the server as new but the main point is how to re-set the Library with all the folders I had without having Plex thinking they are new.

Thanks!!

I have OMV in a VM here.

Can you show me the pathnames you have / use(d) ?
I do better with seeing names and where links go – comparing against my local VM.

I ask because I thought (may be proxmox) puts Plex Plug-in in a container and not in /var/lib/plexmediaserver

If installed directly, on the underlying Debian host, then I am in sync.
It’s only the mapping from “plug-in” to actual where I am unclear.

Two servers on the same host speaks loudly to having a container and the main host (separate network namespaces)

For pathnames you mean the Library location?
If so that’s /var/lib:

lrwxrwxrwx 1 plex plex 27 Apr 15 2018 plexmediaserver -> /mnt/raid5/plexmediaserver/

btw this worked for years and years so haven’t changed anything in this sense if it can help.

OMV as far as I can tell it’s not using docker for plex (yet) just old style plugin which comes with a web frontend (nothing special) and the actual plexmediaserver is sthe standard debian base. As a matter of fact I always update plex via apt-get

Finally the two servers are on two different VMs on different ESX servers on different sites

Thanks for that.

  1. As far as PMS is concerned, it’s using the default location.
  2. You rsync'd the `/mnt/raid5/plexmediaserver directory?
  3. If so, we can pull it back, as a tar-ball (faster than rsync) and put it back into position as if a full backup , possibly switching to a backup of the DB, and having it refresh everything , without losing.
  4. If you’d like, while restoring, we can migrate you to a systemd override file and avoid future dependency on the symbolic link or an overlaying bind mount.
  1. good
  2. no I think rsync on a file basis is way faster since my Library is abour 9GB
  3. this is what I have done already (restored from backup server onto primary), however the Preference.xml was overwritten so I moved it and allowed Plex to create one. Can you please elaborate on the backup of the DB part?
  4. I don’t have any issue keeping the symlink but please explain better this option as well

The main issue though (as per OP) the day before the system crashed both primary and backup lost the “database definition”, so it’s now asking me to specify where to find the media. With this in mind even restorinf the full Library I’m not expecting this to work out of the box.

I did (as a test) add one of the media folder having the Library restored already but it starts a brand new scan. Is it worth trying to specify where the media lives at config file level? If so what fil needs to be modified?

Thanks

  1. FYI only : cd source dir; tar cf - . | (cd dest dir ; tar xf -) is a read-send through the memory pipe-write it as it comes out. Because it’s two processes, it’s more async than rsync you have two independent i/o sets active (i’ve timed it for my Plex backups). That said, do what you are most comfortable with

The “backup” copy of the DB is very straight forward.

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

This is my QNAP – for reference

[/share/CACHEDEV3_DATA/.qpkg/PlexMediaServer/Library/Plex Media Server/Plug-in Support/Databases] # ll
total 2.8G
drwxr-xr-x 2 admin administrators 4.0K 2020-10-26 02:00 ./
drwxr-xr-x 7 admin administrators 4.0K 2020-06-29 20:34 ../
-rw-r--r-- 1 admin administrators 8.7M 2020-10-22 02:00 com.plexapp.plugins.library.blobs.db
-rw-r--r-- 1 admin administrators 8.7M 2020-10-17 02:01 com.plexapp.plugins.library.blobs.db-2020-10-17
-rw-r--r-- 1 admin administrators 8.7M 2020-10-20 02:00 com.plexapp.plugins.library.blobs.db-2020-10-20
-rw-r--r-- 1 admin administrators 8.7M 2020-10-23 02:00 com.plexapp.plugins.library.blobs.db-2020-10-23
-rw-r--r-- 1 admin administrators 8.7M 2020-10-26 02:00 com.plexapp.plugins.library.blobs.db-2020-10-26
-rw-r--r-- 1 admin administrators  96K 2020-10-22 02:00 com.plexapp.plugins.library.blobs.db-shm
-rw-r--r-- 1 admin administrators 8.9M 2020-10-22 02:00 com.plexapp.plugins.library.blobs.db-wal
-rw-r--r-- 1 admin administrators 481M 2020-10-27 16:33 com.plexapp.plugins.library.db
-rw-r--r-- 1 admin administrators 362M 2020-10-17 02:01 com.plexapp.plugins.library.db-2020-10-17
-rw-r--r-- 1 admin administrators 495M 2020-10-20 02:00 com.plexapp.plugins.library.db-2020-10-20
-rw-r--r-- 1 admin administrators 481M 2020-10-23 02:00 com.plexapp.plugins.library.db-2020-10-23
-rw-r--r-- 1 admin administrators 481M 2020-10-26 02:00 com.plexapp.plugins.library.db-2020-10-26
-rw-r--r-- 1 admin administrators 3.8M 2020-10-27 18:53 com.plexapp.plugins.library.db-shm
-rw-r--r-- 1 admin administrators 493M 2020-10-27 18:53 com.plexapp.plugins.library.db-wal
[/share/CACHEDEV3_DATA/.qpkg/PlexMediaServer/Library/Plex Media Server/Plug-in Support/Databases] # 

You’ll see com.plexapp.plugins.library.db (your current DB) and some backups (with “-date” suffixes).

To use one.

  1. Stop PMS

  2. If the com.plexapp.plugins.library WAL or SHM file still exists – Remove it/them

  3. mv com.plexapp.plugins.library.db com.plexapp.plugins.library.db-previous

  4. cp com.plexapp.plugins.library.db-some_date com.plexapp.plugins.library.db

  5. chown plex:plex com.plexapp.plugins.library.db

You’re now about to use the Database as of that date:

Start PMS

For each library section

  1. Scan all files
  2. Refresh all metadata for each section to recreate any missing bundles
  3. Allow to finish
  4. Empty Trash
  5. Clean Bundles
  6. Optimize the database

Now advance to the next section and repeat until done.

OK I’ve sort of done the db part even though I did not have the -date suffiix anywhere.

About the latter part, before I go into that, I’m now experiencing something some strange issues relatet to server visibility and account::

  • On the Secondary Server web interface I see the Secondary server only (itself), which is strange as I had both servers linked to my account before,

  • On the primary server (where I’m performing the actions you’re suggesting) I see neither the local nor the secondary plex server. I have tried logging on/off multiple times but it doesn’t seem to find it:


    However the process seems to be working:

So essentially I’m currently unable to operate the primary plex server from the web interface.

That’s good that you’re running.

One of plex/web’s weaknesses is handling a new server when there is already another defined.

There is a very simple, albeit annoying, way to get it associated.

  1. Go https://app.plex.tv
  2. Click over to Settings - Authorized Devices - Servers (dropdown)
  3. Look for the old server name and “X” (Remove) it/them.
  4. Sign Out of Plex/web (upper right) – this step is important.
  5. Open a SSH tunnel to the other machine ssh -L 8888:127.0.0.1:32400 ip.addr.of.host
  6. Sign in on that host and let the session sit idle.
  7. Open a new Incognito browser window
  8. In that browser window, open URL http://127.0.0.1:8888/web
  9. The plex/web on the other machine will load – Let me know if you get errors here
  10. If it’s ready to be initialized (setup wizard) or claimed, it will want you to sign in.
  11. Sign in.
  12. If the setup wizard runs, click your way through it, checking settings as you do.
  13. Your Library sections are still there (stored in the Database) so SKIP creating new library sections
  14. When FINISHed, you’ll arrive at the dashboard and should see your library sections there waiting for you.
  15. you should also see your other server there now.
  16. Check this server’s settings because they will have been reset to defaults.
  17. When all is done, Close the browser window and exit the ssh session.

Ok I actually fixed the “unseen” server logging into my account via VPN. Regardless this is now fixed. I’m now looking into the database issue.

Re-reading one of your posts above:

  • Scan all files
  • Refresh all metadata for each section to recreate any missing bundles

Scanning is is exactly what I was trying to avoid as there’s a large amoutn of manual match I did in the past to the plex not matching automatically. Following this procedure is a new match performed (asking as this would be unwanted)?

To recap where I am now is:

  • Account has both servers associated
    -After the db restore procedure described above onto the primary it seems like ti takes sometimes to start the process and actually it failes after few seconds:

I’m wondering if I’m doing anything wrong
Thanks

Ok I think I progressed greately thanks to all the info you provided me!

I had to install the prev version as I guess there’s a dependency betwen database and plexmediaserver version. So I think this is what was making my plex process failing.

Followed the steps above (copied db, re-define the library, scan + update metadata) and eveyrthing (almost) seems to be in there now.

There are a couple af secondary issues that still bother me but I’m unsure if I can fix this (still very happy of where I am)

Here’s the issues:
1- I have lost all the “watched” information

2- It seems like the “Last Added” sorting refers to added in the database as I understand not on the filesystem so Last added is actually = Aphabetical right now. Wondering if Last added to the filesystem sorting is possib le or perhas this can be a featire request?

3 Some titles are not matched however if I do a manual match the very fist occurence is the correct one, not sure why this is happening. It seems like Plex has skipped them for whatever reason.

4 While refreshing the metadata I get these errors:


Following some reading in Internet I:
a. stopped plex
b. removed the content of: /Library/Application Support/Plex Media Server/Plug-in Support/Data
c. started plex
it seems like the content has been recreated automatically however (reduced) I still get some of these errors in the console.

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