Problems with PMS and Plex App after rebuild/recovery of media source drive

Server Version#: 3.95.2
Player Version#: 7.17.2.11085

This all happened a few weeks ago and I have only now had ime to document it, so bear with me. Plex problems come into it half way through.

Scenario: I had been backing up my Plexmediaserver folder (located in /var/lib) to my NTFS backup drive with Luckybackup. I started getting errors in the backup. So decided to delete the complete backup folder and contents on the NTFS drive and start again (under Windows as I can’t do it in Linux as /var is always mounted of course). So deleted most by renaming folders etc. due to the stupid Windows 256 character path limit! Anyway I couldn’t delete some files and asked for help in another forum.

Anyway long story short someone in the other forum said run chkdsk on the drive. Did that and chkdsk stuffed up the Master File Table for the drive and Windows wouldn’t mount it. So I re-ran chkdsk and Windows mounted it…BUT ALL my files were gone – the drive was empty!
Instead of spending a month recovering the files from the disk I found I could recover almost all of the folders and files from my backups and other drives So I did that.

Here is where the problems with Plex start.
When I first got into Plex via the browser I got asked to set up my media. (I can’t remember if I had to login then or after) BUT, when I went into set them up again, the paths were already there. ???

Anyway, the first time I went to watch something via my Android Plex app (I had to reactivate to say I had already purchased it for some odd reason!), the Home screen has big red “OFFLINE” blocks on the OnDeck and recently added TV and Movies sections! ???

If I go into “Sources” (via the “…More > All Shows > Sources” for both TV and Movies - I find I now have 2 separate entries for my computer name! One that specifies OFFLINE in the Red box and the other not. If I select the one without the Red OFFLINE box I can get to my TV shows and Movies. Okay, seemingly all good. BUT, more problems. For every TV show or Movie, I have the Orange rectangle (or Triangle) with numbers in it for every TV show! Or Movie!! Yet when I get into the individual seasons listing for TV shows and it only seems to be the latest seasons and episodes that are flagged as having been watched – ALL the previous seasons of ALL the TV shows (and every single Movie) are flagged as not having been watched!
So, what is going on? What have I done incorrectly???
Is there some way I can fix this or do I have to live with these problems??
Annoying and frustrated.

You can’t use Windows tools or techniques to backup Linux. It will always lead to what you have encountered here.

The simplest and safest is to make a Linux tar archive (like a zip but contains all the needed information).

Given you have two servers now and massive misplaced data, the best way to sort this all out is to start over.

While Linux is running:

  1. In Plex/Web - Settings - Devices - Delete the servers (both of them)
  2. Uninstall Plex
  3. Delete the Plex user (userdel command)
  4. Remove /var/lib/plexmediaserver and all files and directories underneath it. ( rm -rf)
  5. Reinstall plex and begin again.

In the future, never copy to NTFS and never use a Windows utility.
You can create a Linux tar archive (referenced above) using this How-To.
Containerd therein is how to restore the backup should you need to.
It is permitted, if you follow the NTFS naming rules, to store the tar file itself on a NTFS disk provided you are writing it from Linux → NTFS.

ChuckPA, I am not using a Windows tool to backup PMS. LuckyBackup is a Linux tool. LB is a graphical front-end for rsync. LB just plugs all of the correct rsync parameters for what you select in the Graphical front-end. So even that won’t work going to an NTFS drive?
If that is so I will have to use your method from now on in case of drive failure.
And yes, I thought to fix this mess I would have to un-install and re-install Plex. Darn it!

The problem with NTFS is there is no UID/GID information fields nor are there permission bits.
NTFS is based on ACL permission lists.

Yes, ext4 supports ACLs, but they aren’t often used and Plex itself doesn’t use them. It relies on the least common denominator (UID/GID).

You can try to restore.
It will bring all the files back.

Since rsync back onto an ext formatted volume will result in UID/GID and permissions values being all wrong. They will be all owned by root with 777 permissions.

If you really want to try this:

  1. Restore from the NTFS backup into a test directory.
  2. At the top of the test directory, type the following:
sudo sh  (if not already root)
chown -R plex:plex .
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

This will put it all back to right assuming date/time stamps are preserved properly by the NTFS destination when rsync is done.

I find that tar is simple and universal. I can write a tarball onto a NTFS volume , and be 8.3 compliant, with ease.

ChuckPA, thaks so much once again (you helped me out a year or so ago when you told me about the plex:plex permissions and exactly what folders/files I needed to be able to restore PMS. So, going forward I will use your method as you have vastly more experience than I. Plus restoring everything in one hit out of a tarball/zip file seems a lot easier. I have saved his chat as well for future reference (as I did the previous one).
Very grateful for all your help, most appreciated.

ChuckPA, one other thing (just reading through your method). So in the command lines

sh-4.4# tar cfz /nas/tmp/PlexBackup.tar.gz ./Library
sh-4.4# ls -la /nas/tmp/PlexBackup.tar.gz 

Do I have to replace /nas/tmp with another etx4 destination, then copy the zip file to my NTFS drive or just zip it straight onto my NTFS drive? I just want to be clear about it before stuffing things up again. But being sure about it means I can be sure I'll be able to recover PMS.
Thanks for putting up with me.

You can place the PlexBackup file on NTFS. All the needed information is contained inside the file.

I did forget, due to the late hour of my reply, Correct 8.3 naming would be PlexBkup.tgz
Linux doesn’t care but this way, you avoid two dots in the name. I don’t know how Windows behaves in that case.

Thanks ChuckPA, much obliged. I was pretty such that is what was meant but I just wanted to be certain before embarking on this new endeavour. And yes the 8.3 naming in NTFS/Windows is better so I will go with that.
Again, thanks so much for your help and patience with me. elieve it or not I did used to be in IT when I was working, but that was in a purely Windows world. I have been using Linux as my main desktop since 2009, but dabbled from early mid 1990s, just dipping my toe in the water so to speak, so I am not fantastic at Linux but I can get by.

I started with all this stuff in the 1970’s. Back when punched cards and tape were the thing.
From there… Fortran and big machines… eventually into Unix/C in 83. When Linux came around, I jumped over.

My experience with Windows is very much residual from the PC-DOS 3.1 days
… and grabbing glass cleaner.

I actually started as a computer operator on a mainframe (of sorts) with punch cards, disk packs and tapes back in the mid-70s.Left to go OS, came back did various jobs; system programmer on an IBM mainframe, then past IT security for several years and ended up heading up a team that looked after the Data/shared drives on servers shared by all the users in our Federal Government department till early retirement 7 years ago.

Just another question about the code, what is the trailing ./Library for in the line:
sh-4.4# tar cfz /nas/tmp/PlexBackup.tar.gz ./Library

Do I need it for my backup code or is it something you use specifically?

You also need the

cd /var/lib/plexmediaserver

to place you in the correct directory (above the Library directory)

The tar statement is of the form **tar options destination-file source-file(s)

Therefore. ./Library and all below it is what goes into the tar backup file.

Okay, thaks for that Chuck. Ill give it a go soon and let you know how I get on.

ChuckPA, Sorry for the tardy reply (there has been a lot going on around here lately). I have done couple of runs of the tar process and it seems to workas specified. The native size of plexmediaser in /var was 2.8Gb and the tat.gz file size is is 1.9Gb. Does that sound about right?

Yes. That sounds about right. The tarball (as we call it), it always smaller because the filesystem will use 4K bytes (1 page) for a 200 byte file whereas the tarball will use 200 + name length bytes. It’s always a bit smaller for that reason.

I knew it would be smaller, just wanted to check that the sizing was about correct - which you say it is.SO all good, Ill use this method in the future. Thanks once again for all your invaluable help, I really appreciate it.

You’re welcome.

If you want to verify everything is there, there’s a simple test:

  1. cd /var/lib/plexmediaserver ; sudo find . -print | wc -l (counts the number of files)
  2. tar tf /path/to/tarball.tgz | wc -l (counts the number of files in the tar ball)

Both commands print the files found, one per line. This makes it easy for wc (word counter) to count the number of lines and report.

Thanks for that, most appreciated once again. I have saved these commands to the doco I have created for this.

ChuckPA,
I have a new 4Tb HDD NTFS drive to replace (what I suspect is) the dodgy original HDD that houses my Media Libraries. But, before I copy/backup my media library files to the new drive, I was wondering if you could clarify something for me. If I make a change say to the description details or a poster for a movie or a TV episode and save those changes - where do those changes get saved to? Are those changes saved to /var/lib/plexmediaserver or directly to my media library which is located on the NTFS drive?
The answer will dictate how I proceed from here to replace the dodgy NTFS HDD that houses my current media libraries.
As always, any help/guidance is greatly appreciated.

The changes are maintained entirely in Plex’s database.

A cardinal rule here:

  1. Plex will never modify your media

with the singular exception:

  1. Plex will only delete media when commanded and
    After you enable media deletion in Settings - Server - Library - Show Advanced

ChuckPA,
Thankyou so much for that. That’s what I was hoping you would say.
As always, you’re help is very much appreciated.

Another question. Does PMS have to be installed into /var/lib or is there an option to move/re-install into its own folder separate from /var? Just wondering.