Reinstall OS Ubuntu 18 to 20.04 and had to set it all up again (Solved)

My server would not update from Ubuntu 18 to 20 So I backed it up and installed a fresh Ubuntu 20.04.3 server.

Had to set all back up like it was. Database and web. Got it working good.

Installed Plax with the .deb package and have to scan all my media again.

Got a backup where is the file I can restore so Plex will see all my media again and don’t have to set it all up again. I guess it’s the Plex database and it was not in the like built in database it must have it’s own?

Still have the old URL to my place open I don’t want to refresh it so I can see how it was. All the folders I had set up have yellow round ! icons next to them. So it lost them looks like.

-Raymond Day

I think I found were it is stored.

/usr/lib/plexmedaserver

I rename it with just a ~ on the end and then made a link with the same name to were it is on my back up.

Refreshed the URL but page can’t be displayed then.

So I renamed it back how it was and refreshed the page and it comes up then but none of my old database.

-Raymond Day

Just did a link to the:

/usr/lib/plexmediaserver/lib

Same place at my backup and refreshed the URL and looks like it was going to work but I get a yellow round ! next to each folder on the left side still. I guess all most had it.

-Raymond Day

The package binaries are in /usr/lib/plexmediaserver.
Your “server” itself is in /var/lib/plexmediaserver.

Do you have a backup of that area?

Yes I back it up all. I made a link to the backup to Link shortcut /usr/lib/plexmediaserver to /media/WD-MyDrive-2TB/plexmediaserver were the backup is.

Renamed the new /usr/lib/plexmediaserver folder to /usr/lib/plexmediaserver~ so I did not delete it.

But when I got to the URL I get a 404 Not Found error.

Then rename the link back how it was refresh the link it it comes up takes a little bit and all my folders show up at the left side but with ! on each of them.

Have some links I pointed to the back up in the /usr/lib/plexmediaserver folder.

The /lib is a link to my backup.

That seems to get the names of the folders but not that database I guess.

-Raymond Day

Raymond,

I think you’re confusing or not understanding how this all works and ultimately breaking things.

I also believe the default Ubuntu installation helped confuse things too (much like the default Windows installations do)

In Linux, Packages and their data are often stored in different locations.
In Plex, We use two locations which look the same but aren’t.

  1. We place the software (using apt-get) into /usr/lib/plexmediaserver
  2. We place the data, which is what makes your server what it is, in /var/lib/plexmediaserver

When you reinstall, the ubuntu installer will force a reformatting of the HD UNLESS you tell it to do something else.

Just like with Windows, you can create partitions. When you do this, from that point forward, you can separate your data from the operating system.

In my configuration, I have

  1. The / partition which is where Ubuntu resides
  2. A /home partition where all my data (which includes my login directory and everything I use the computer for.
  3. I then customized Plex to place its metadata (the stuff which is your actual Plex server) in the /home partition.

Now, if I have to reinstall the OS (which I just did a few days ago).

  1. I reformat the OS partition (/)
  2. I keep the Home partition (/home)
  3. After installation,
    a. Reinstall the Plex software
    b. Add my Plex configuration file back to the OS installation (which is a very small file)
    c. PMS starts up and has no clue whatsoever that anything was reinstalled. To it, everything is normal.

Would you like something like this so that you aren’t plagued with losing your Plex server in the future?

I can boot the backup. So I guess I can Do what you did on “B. ADD my Plex configuration…”

How do I save that and then how to I put it back to it?

I don’t have my /home. I’t at /media on a lot of hard drives.

I don’t want to start over because I have a lot of info on my videos. I put info text on a lot of them. It took years to do that.

I still get “not Found” because I copy the backup to the same place /usr/lib/plexmediaserver and then I get Not found in :32400/web/index.html# now.

But when I do a htop it shows that plexmedaserver is working. It’s doing something. But the web not not work. Because I copied the backup to the same place. So there must be a database some place. How can I copy that from the backup? I don’t know were it saves it.

Thank you.

-Raymond Day

There are two steps which work together.

These two How-TO’s overlap and give you more options.

This will move PMS from /var/lib/plexmediaserver to wherever you want it

This is the supplement which shows how you can futher customize it.

Did this command to copy plexmediaserver folder from the back up to the new install.

rsync -avP /media/3TB-Black-laptop-size/var/lib/plexmediaserver/ /var/lib/plexmediaserver

Added plex so I could just do a apt install -y plexmediaserver command.

But still don’t work when I got to the URL.

Did this command to see why.

root@server:~# systemctl status plexmediaserver
● plexmediaserver.service - Plex Media Server
Loaded: loaded (/media/3TB-Black-laptop-size/lib/systemd/system/plexmedias>
Active: failed (Result: exit-code) since Sat 2020-09-26 10:25:33 EDT; 14s >
Process: 73478 ExecStartPre=/bin/sh -c /usr/bin/test -d “${PLEX_MEDIA_SERVE>
Process: 73484 ExecStart=/bin/sh -c export PLEX_MEDIA_SERVER_INFO_VENDOR=”>
Main PID: 73484 (code=exited, status=1/FAILURE)

Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Scheduled restart j>
Sep 26 10:25:33 server systemd[1]: Stopped Plex Media Server.
Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Start request repea>
Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Failed with result >
Sep 26 10:25:33 server systemd[1]: Failed to start Plex Media Server.
lines 1-12/12 (END)
● plexmediaserver.service - Plex Media Server
Loaded: loaded (/media/3TB-Black-laptop-size/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-09-26 10:25:33 EDT; 14s ago
Process: 73478 ExecStartPre=/bin/sh -c /usr/bin/test -d “{PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "{PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}” (code=exited, status=0/SUC>
Process: 73484 ExecStart=/bin/sh -c export PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= “{print $2}” | tr -d " )"; export PLEX_MEDIA_SERVER_INFO_DEVICE=“PC”; expo>
Main PID: 73484 (code=exited, status=1/FAILURE)

Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Scheduled restart job, restart counter is at 3.
Sep 26 10:25:33 server systemd[1]: Stopped Plex Media Server.
Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Start request repeated too quickly.
Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Failed with result ‘exit-code’.
Sep 26 10:25:33 server systemd[1]: Failed to start Plex Media Server.

I don’t get why it’s trying to run it from the backup drive. That my be the problem now sure.

How can I do this? It looks like the Database is in with the /var/lib/plexmediaserver folder…

-Raymond Day

what does journalctl -xe | grep -i plex show for errors?

I suspect you’ll find “permission denied” because the UID/GID is likely to have changed.

The errors you show above make it look like

PLEX_MEDIA_APPLICATION_SUPPORT_DIR=/media....

How long / how experienced are you with Linux.
I get the feeling you’re not that comfortable with the command line?

Know some about the command line not a lot. At work don’t know anyone that knows Linux at all. I know some commands in my head.

Any way I did what you said the command shows this:

root@server:~# systemctl status plexmediaserver
● plexmediaserver.service - Plex Media Server
     Loaded: loaded (/media/3TB-Black-laptop-size/lib/systemd/system/plexmedias>
     Active: failed (Result: exit-code) since Sat 2020-09-26 10:25:33 EDT; 1h 2>
   Main PID: 73484 (code=exited, status=1/FAILURE)

Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Scheduled restart j>
Sep 26 10:25:33 server systemd[1]: Stopped Plex Media Server.
Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Start request repea>
Sep 26 10:25:33 server systemd[1]: plexmediaserver.service: Failed with result >
Sep 26 10:25:33 server systemd[1]: Failed to start Plex Media Server.
root@server:~# journalctl -xe | grep -i plex
Sep 26 11:32:45 server root[75130]: PlexMediaServer install: Pre-installation Va                                                                          lidation.
Sep 26 11:32:45 server logger[75134]: PlexMediaServer install: Systemd configura                                                                          tion error detected:
Sep 26 11:32:45 server logger[75136]: PlexMediaServer install: File "/etc/system                                                                          d/system/plexmediaserver.service" is leftover from an earlier Debian/Ubuntu bug.
Sep 26 11:32:45 server logger[75138]: PlexMediaServer install: Please transfer a                                                                          ny customizations \(APP_DIR, User, Group, TMPDIR, and/or UMask\) to a proper "/o                                                                          verride.conf"
Sep 26 11:32:45 server logger[75140]: PlexMediaServer install: and reinstall.
Sep 26 11:32:45 server logger[75142]: PlexMediaServer install: Unit override "/e                                                                          tc/systemd/system/plexmediaserver.service" found.
Sep 26 11:32:45 server logger[75144]: PlexMediaServer install: Only "/etc/system                                                                          d/system/plexmediaserver.service.d/override.conf" is supported.
Sep 26 11:32:45 server logger[75190]: PlexMediaServer install: Pre-installation                                                                           Validation failed.
Sep 26 11:32:45 server logger[75192]: PlexMediaServer install: Configuration inf                                                                          ormation discovered:
Sep 26 11:32:45 server logger[75194]: PlexMediaServer install:   Installation Ty                                                                          pe:  New
Sep 26 11:32:45 server logger[75196]: PlexMediaServer install:   Process Control                                                                          :    systemd
Sep 26 11:32:45 server logger[75198]: PlexMediaServer install:   Plex User:                                                                                    plex
Sep 26 11:32:45 server logger[75200]: PlexMediaServer install:   Plex Group:                                                                                   plex
Sep 26 11:32:45 server logger[75202]: PlexMediaServer install:   Video Group:                                                                                  render
Sep 26 11:32:45 server logger[75204]: PlexMediaServer install:   Metadata Dir:                                                                                 /var/lib/plexmediaserver/Library/Application Support
Sep 26 11:32:45 server logger[75206]: PlexMediaServer install:   Temp Directory:                                                                               /tmp
Sep 26 11:32:45 server logger[75208]: PlexMediaServer install:   Lang Encoding:                                                                                en_US.UTF-8
Sep 26 11:32:45 server logger[75210]: PlexMediaServer install:   Transcoding HW:                                                                               Found
Sep 26 11:32:45 server logger[75212]: PlexMediaServer install: Pre-installation                                                                           Validation complete.
Sep 26 11:33:36 server root[75276]: PlexMediaServer install: Pre-installation Va                                                                          lidation.
Sep 26 11:33:36 server logger[75280]: PlexMediaServer install: Systemd configura                                                                          tion error detected:
Sep 26 11:33:36 server logger[75282]: PlexMediaServer install: File "/etc/system                                                                          d/system/plexmediaserver.service" is leftover from an earlier Debian/Ubuntu bug.
Sep 26 11:33:36 server logger[75284]: PlexMediaServer install: Please transfer a                                                                          ny customizations \(APP_DIR, User, Group, TMPDIR, and/or UMask\) to a proper "/o                                                                          verride.conf"
Sep 26 11:33:36 server logger[75286]: PlexMediaServer install: and reinstall.
Sep 26 11:33:36 server logger[75288]: PlexMediaServer install: Unit override "/e                                                                          tc/systemd/system/plexmediaserver.service" found.
Sep 26 11:33:36 server logger[75290]: PlexMediaServer install: Only "/etc/system                                                                          d/system/plexmediaserver.service.d/override.conf" is supported.
Sep 26 11:33:36 server logger[75336]: PlexMediaServer install: Pre-installation                                                                           Validation failed.
Sep 26 11:33:36 server logger[75338]: PlexMediaServer install: Configuration inf                                                                          ormation discovered:
Sep 26 11:33:36 server logger[75340]: PlexMediaServer install:   Installation Ty                                                                          pe:  New
Sep 26 11:33:36 server logger[75342]: PlexMediaServer install:   Process Control                                                                          :    systemd
Sep 26 11:33:36 server logger[75344]: PlexMediaServer install:   Plex User:                                                                                    plex
Sep 26 11:33:36 server logger[75346]: PlexMediaServer install:   Plex Group:                                                                                   plex
Sep 26 11:33:36 server logger[75348]: PlexMediaServer install:   Video Group:                                                                                  render
Sep 26 11:33:36 server logger[75350]: PlexMediaServer install:   Metadata Dir:                                                                                 /var/lib/plexmediaserver/Library/Application Support
Sep 26 11:33:36 server logger[75352]: PlexMediaServer install:   Temp Directory:                                                                               /tmp
Sep 26 11:33:36 server logger[75354]: PlexMediaServer install:   Lang Encoding:                                                                                en_US.UTF-8
Sep 26 11:33:36 server logger[75356]: PlexMediaServer install:   Transcoding HW:                                                                               Found
Sep 26 11:33:36 server logger[75358]: PlexMediaServer install: Pre-installation                                                                           Validation complete.
root@server:~#

-Raymond Day

Would you please do the following and paste the results:

  1. Terminal Window
  2. cat /tmp/plexinstaller.log

This will tell me what the installer saw for the configuration.

Be certain to have a wide enough terminal window so the right side isn’t chopped off like above is.

If there is no /tmp/plexinstaller.log, please run it again (there is no harm), then
get the installer’s log file for me.

Also, Please show me what is in /etc/systemd/system/plexmediaserver.service ?
(cat /etc/systemd/system/plexmediaserver.service )

What I’ll try to do for you is resolve the configuration changes / differences and get you a working configuration

Thanks.

> root@server:~# cat /tmp/plexinstaller.log
> cat: /tmp/plexinstaller.log: No such file or directory
> root@server:~# /etc/systemd/system/plexmediaserver.service
> -bash: /etc/systemd/system/plexmediaserver.service: Permission denied
> root@server:~# cat /etc/systemd/system/plexmediaserver.service
> # DO NOT EDIT THIS FILE DIRECTLY!
> #
> # Plex Media Server's variables can be customized by creating an 'overide.conf'
> # file using 'systemctl edit plexmediaserver' which will create the following;
> # /etc/systemd/system/plexmediaserver.service.d/override.conf
> #
> # An example of the override.conf would be as follows if you wished to edit
> # your user, group, temp directory, or app support directory (without the leading #)
> #
> # [Service]
> # Environment="TMPDIR=/path/to/new/tmp"
> # Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/home/myusername/Library/Application Support"
> # User=myusername
> # Group=mygroup
> #
> 
> [Unit]
> Description=Plex Media Server
> After=network.target network-online.target
> 
> [Service]
> Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application Support"
> Environment=PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
> Environment=PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
> ExecStartPre=/bin/sh -c '/usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}"'
> ExecStart=/bin/sh -c '\
> export PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )"; \
> export PLEX_MEDIA_SERVER_INFO_DEVICE="PC"; \
> export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"; \
> export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )"; \
> export LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib; \
> exec "/usr/lib/plexmediaserver/Plex Media Server"'
> Type=simple
> User=plex
> Group=plex
> Restart=on-failure
> RestartSec=5
> StartLimitInterval=60s
> StartLimitBurst=3
> SyslogIdentifier=Plex Media Server
> StandardOutput=journal
> StandardError=journal
> 
> [Install]
> WantedBy=multi-user.target
> root@server:~#

It has the number sign before some text that is not code and makes it look big in this post.

Al lso the cat the /etc/systemd/system/plexmediaserver.service is a link to my backup here /media/3TB-Black-laptop-size/lib/systemd/system/plexmediaserver.service Just set that to 755.

So now that command works like this:

root@server:~# /etc/systemd/system/plexmediaserver.service
/etc/systemd/system/plexmediaserver.service: line 17: [Unit]: command not found
/etc/systemd/system/plexmediaserver.service: line 18: Media: command not found
/etc/systemd/system/plexmediaserver.service: line 19: network-online.target: command not found
/etc/systemd/system/plexmediaserver.service: line 21: [Service]: command not found
/etc/systemd/system/plexmediaserver.service: line 25: -c: command not found
/etc/systemd/system/plexmediaserver.service: line 26: -c: command not found
/etc/systemd/system/plexmediaserver.service: line 40: Media: command not found
/etc/systemd/system/plexmediaserver.service: line 44: [Install]: command not found
root@server:~#

-Raymond Day

removed the apt install with apt remove and then used the plexmediaserver_1.20.2.3343-c91f25744_amd64.deb but it would error saying that /etc/systemd/system/plexmediaserver.service was installed so it errored.It’s a link to my backup.

So I renamed that link with a ~ at the end so plexmediaserver.service~ Then the .deb package installed and I looked and it made a new plexmediaserver.service link to my old backup again.

Went to the URL and it just shows like it’s a new install starting fresh.

It does see that it’s me I can click on my icon with my face and do the pin. Just logging on to my LAN server. I can get to it over the WWW too.

-Raymond Day

Tested the WWW of it. https://app.plex.tv/desktop and it came up with all my folders on the left side. But with round balls with ! in them all.

So I refreshed the LAN one and it is the same as the WWW now with all my folders having errors.

Wow the online one did something.

-Raymond Day

Like I said I can boot my old backup still It was on a 2TB SSD and I back it up to a HDD and can boot from that.

Can I then use Plex to save it’s database then and restore it on the new load?

-Raymond Day

Now if I go the 1st command you said I get this back:

root@server:~# cat /tmp/plexinstaller.log

Plex Media Server installation configuration info: Sat Sep 26 15:53:09 EDT 2020

Init=0
Systemd=1
Custom=0
LinuxContainer=0
NewInstall=1
HaveOverride=0
OverrideFile=“”
PlexUser=“plex”
PlexGroup=“plex”
VideoGroup=“render”
AppSuppDir=“/var/lib/plexmediaserver/Library/Application Support”
PlexTempDir=“/tmp”
LangEncoding=“en_US.UTF-8”
ExistingVersion=0
HaveHardware=1
HaveTranscoderPref=0
NeedUser=0
NeedGroup=0
NeedVideo=0
Verbose=1
Running=0
Errors=0
Warnings=0
Platform=“To Be Filled By O.E.M.”
Processor=“Intel(R) Core™ i7-6785R CPU @ 3.30GHz”
Distro=“Ubuntu 20.04.1 LTS”
Kernel=“Linux server 5.4.0-48-generic #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux”
Memory=“32019 751 691”
root@server:~#

-Raymond Day

That tells me your PMS installation is completely standard.

All the metadata belongs in /var/lib/plexmediaserver/Library/Application Support

Absolutely nothing of /usr/lib/plexmediaserver matters.

In the next post, I will help you to properly customize PMS.
Your current optimization technique isn’t support (I adhere to the standard).

After reviewing the file in /etc, I see nothing special in there. Therefore, please type the following commands

These two command remove the errant file and instruct linux to rescan.

sudo rm -f /etc/systemd/system/plexmediaserver.service
sudo systemctl daemon-reload

Now to the task of your actual Plex software and to your actual Plex metadata (everything that makes it your server)

  1. There is nothing user-maintainable in /usr/lib/plexmediaserver.
  2. You have made mention of a backup on /media. Can you show me the contents of that please?

May I see this data (a listing or screenshot of the directory contents) ?