ChuckPa / PlexDBRepair

Database repair utility for Plex Media Server databases
Other
705 stars 39 forks source link

Cannot stop PMS. Server reports no content afterwords #166

Open liquid-ion opened 2 days ago

liquid-ion commented 2 days ago

Hello,

Have been running PlexDBRepair on a weekly basis since January. Today I went to check DB again, noticed that DBRepair gives an error that it cannot stop the database.

Docker PMS appears working prior to starting DBRepair. Connection is in green status, content is playing on clients.

DBRepair tries to stop the server and start the status check. It errors after 30seconds saying the server couldn't be stopped. Immediately afterwords I notice the server becomes unreachable/no WebUI from the internal address (the 192.168.X.XXX address).

Restart PMS container, everything is ok again.

Is there a way to use DBRepair if it can't stop PMS while it runs in the docker container console?

Thanks

ChuckPa commented 2 days ago
  1. Stop the container
  2. Use the manual mode (examples in the README) how to specify the paths to Plex SQLite and the databases.
liquid-ion commented 2 days ago

Sorry to impose on you like this, I'm getting the following error when I try to execute manually in my unraid terminal, do you see anything wrong with this? I do not know Linux well so any help appreciated:

I modeled off this example:

root@Jasper:/mnt/user/appdata/PlexMediaServer# /tmp/DBRepair.sh --databases /mnt/user/appdata/PlexMediaServer/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/ --sqlite /var/lib/docker/btrfs/subvolumes/4bb78fb70589d4d2ba56754f4d6bc0edd4cdaa8eab7986943767e09a66cefd19/usr/lib/plexmediaserver/

This is my SQLite location:

/var/lib/docker/btrfs/subvolumes/b45db925b9ea70d255dacf0485930f64684dec4f1cf4382f10c1c63426d38ed4/usr/lib/plexmediaserver/Plex SQLite

The command I'm running:

root@LIBRARY:/mnt/user/appdata/Plex-Media-Server# /mnt/user/appdata/Plex-Media-Server/DBRepair/DBRepair.sh --databases /mnt/user/appdata/Plex-Media-Server/Library/Application\ Support/Plex\ Media\ Server/Plug-In\ Support/Databases/ --sqlite /var/lib/docker/btrfs/subvolumes/b45db925b9ea70d255dacf0485930f64684dec4f1cf4382f10c1c63426d38ed4/usr/lib/plexmediaserver/

The error: [2024-06-28 13.28.00] Error: Unknown host. Current supported hosts are: QNAP, Syno, Netgear, Mac, ASUSTOR, WD (OS5), Linux wkstn/svr, SNAP [2024-06-28 13.28.00] Current supported container images: Plexinc, LinuxServer, HotIO, & BINHEX [2024-06-28 13.28.00]
[2024-06-28 13.28.00] Are you trying to run the tool from outside the container environment ?


What am I doing wrong?

ChuckPa commented 2 days ago

when you specify --sqlite or --databases, it goes into manual configuration mode.

If those values don't work, it jumps back to normal dynamic (automatic) configuration mode.

does

ls -la /var/lib/docker/btrfs/subvolumes/b45db925b9ea70d255dacf0485930f64684dec4f1cf4382f10c1c63426d38ed4/usr/lib/plexmediaserver/

show you the executables as you expect from ls -la on a native host ?

ChuckPa commented 2 days ago

Another option for you:

  1. get into a running container.
  2. there should be the service files in / (Plex docker has it)
  3. from there, /plex_service.sh -d (bring pms down)
  4. now run plex.sh from within the container (be quick)
  5. when done, restart the container
liquid-ion commented 2 days ago

when you specify --sqlite or --databases, it goes into manual configuration mode.

If those values don't work, it jumps back to normal dynamic (automatic) configuration mode.

does

ls -la /var/lib/docker/btrfs/subvolumes/b45db925b9ea70d255dacf0485930f64684dec4f1cf4382f10c1c63426d38ed4/usr/lib/plexmediaserver/

show you the executables as you expect from ls -la on a native host ?

It shows the following output, does this look right?

image

Do I need to include this:

/var/lib/docker/btrfs/subvolumes/b45db925b9ea70d255dacf0485930f64684dec4f1cf4382f10c1c63426d38ed4/usr/lib/plexmediaserver/Plex SQLite

On the command being run?

root@LIBRARY:/mnt/user/appdata/Plex-Media-Server# /mnt/user/appdata/Plex-Media-Server/DBRepair/DBRepair.sh --databases /mnt/user/appdata/Plex-Media-Server/Library/Application\ Support/Plex\ Media\ Server/Plug-In\ Support/Databases/ --sqlite /var/lib/docker/btrfs/subvolumes/b45db925b9ea70d255dacf0485930f64684dec4f1cf4382f10c1c63426d38ed4/usr/lib/plexmediaserver/

I noticed your version did not include that Plex SQLite portion

Another option for you...

Not sure if I understand your instructions, what does "there should be the service files in / (Plex docker has it)" this mean?

I tried running just / in a different running container, but it said permission denied

now run plex.sh from within the container (be quick)

You mean run DBRepair.sh? Not sure what this means.

ChuckPa commented 9 hours ago

In the code, I support both forms:

  1. the directory containing "Plex SQLite" -or-
  2. the full path to "Plex SQLite" (you must escape the space or use quotes)

Observe:

  # Manual configuration options (running outside of container or unusual hosts)
  if [ "$Opt" = "--sqlite" ]; then

    # Is this the directory where Plex SQLite exists?
    if   [ -d "$2" ] && [ -f "$2/Plex SQLite" ]; then
      PLEX_SQLITE="$2/Plex SQLite"
      ManualConfig=1

    # Or is it the direct path to Plex SQLite
    elif echo "$2" | grep "Plex SQLite" > /dev/null  && [ -f "$2" ] ; then
      PLEX_SQLITE="$2"

    else
      Output "Given 'Plex SQLite' directory/path ('$2') is invalid. Aborting."
      exit 2
    fi
    shift 2
  fi

Yes, when using Manual Config, it ignores anything which is preprogrammed. and t is dependent on you to tell it where the databases are (the directory) and where Plex SQLite is.

OOOPS on the plex.sh . I did mean DBRepair.sh. :facepalm:

You can run this from outside the container, with the container stopped, if you have the full path in the real filesystem.

When you run inside the container, I usually:

  1. Put DBRepair.sh under the /config directory
  2. docker exec -it container_name bash
  3. cd /config
  4. /plex_service.sh -d
  5. ./DBRepair.sh auto exit (which will work inside the container for known images)
  6. /plex_service.sh -u
ChuckPa commented 9 hours ago

DOOH.. I think I just found a bug.

    # Or is it the direct path to Plex SQLite
    elif echo "$2" | grep "Plex SQLite" > /dev/null  && [ -f "$2" ] ; then
      PLEX_SQLITE="$2"

    else

When you specify the full path, it doesn't go into manual mode.
Can you tweak that on your end ? (use the ManualConfig=1 above as example.

Your option is to give it the directory name and it will find Plex SQLite there successfully.