Database repair utility for PMS databases - Will not start after running

Server Version#: 1.32.1.6999
Player Version#: 4.100.1
Synology Version#: 7.2-64561 on DS720+

Hi @ChuckPa, I have run the latest version of the DB repair script 1.0.8 and I’m sorry to say the outome is still the same. The PMS will not start afterwards due to what I suspect is a permissions error.

We had a bit of back and forth the other week where you told me I was not running this as root. Myself and another user assured you that we were. In reply to that, you raised a Git issue ‘Require root UID on selective platforms’ but that hasnt worked.

This time, I have grabbed the putty output so you can see what I invoked. Towards the end, you can see it tries to start PMS, thinks it has but checking the staus a few seconds later you can see it is not running. If I try to start it from the Synology gui, same thing, the server will not start. I can recover normal functionality by doing a Btrfs restore so I am not in a panic. I just want you to know the script does not seem to work for all of us.

login as: *****
*****@192.168.0.254's password:

Using terminal commands to modify system configs, execute external binary
files, add files, or install unauthorized third-party apps may lead to system
damages or unexpected behavior, or cause data loss. Make sure you are aware of
the consequences of each command and proceed at your own risk.

Warning: Data should only be stored in shared folders. Data stored elsewhere
may be deleted when the system is updated/restarted.

Could not chdir to home directory /var/services/homes/*****: No such file or directory
*****@SynologyNas:/$ cd /volume3/PlexMediaServer
*****@SynologyNas:/volume3/PlexMediaServer$ sudo bash
Password:
bash-4.4# chmod +x DBRepair.sh
bash-4.4# ./DBRepair.sh



      Plex Media Server Database Repair Utility (Synology (DSM 7))
                       Version v1.0.8


Select

  1 - 'stop'      - Stop PMS
  2 - 'automatic' - database check, repair/optimize, and reindex in one step.
  3 - 'check'     - Perform integrity check of database
  4 - 'vacuum'    - Remove empty space from database
  5 - 'repair'    - Repair/Optimize  databases
  6 - 'reindex'   - Rebuild database database indexes
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky)
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive)
 10 - 'show'      - Show logfile
 11 - 'status'    - Report status of PMS (run-state and databases)
 12 - 'undo'      - Undo last successful command

 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 1

Stopping PMS.
Stopped PMS.

Select

  1 - 'stop'      - Stop PMS
  2 - 'automatic' - database check, repair/optimize, and reindex in one step.
  3 - 'check'     - Perform integrity check of database
  4 - 'vacuum'    - Remove empty space from database
  5 - 'repair'    - Repair/Optimize  databases
  6 - 'reindex'   - Rebuild database database indexes
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky)
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive)
 10 - 'show'      - Show logfile
 11 - 'status'    - Report status of PMS (run-state and databases)
 12 - 'undo'      - Undo last successful command

 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 2

Automatic Check,Repair,Index started.

Checking the PMS databases
Check complete.  PMS main database is OK.
Check complete.  PMS blobs database is OK.

Exporting current databases using timestamp: 2023-06-09_07.15.15
Exporting Main DB
Exporting Blobs DB
Successfully exported the main and blobs databases.  Proceeding to import into new databases.
Importing Main DB.
Importing Blobs DB.
Successfully imported databases.
Verifying databases integrity after importing.
Verification complete.  PMS main database is OK.
Verification complete.  PMS blobs database is OK.
Saving current databases with '-BACKUP-2023-06-09_07.15.15'
Making repaired databases active
Repair complete. Please check your library settings and contents for completeness.
Recommend:  Scan Files and Refresh all metadata for each library section.

Backing up of databases
Backup current databases with '-BACKUP-2023-06-09_07.15.46' timestamp.
Reindexing main database
Reindexing main database successful.
Reindexing blobs database
Reindexing blobs database successful.
Reindex complete.
Automatic Check, Repair/optimize, & Index successful.

Select

  1 - 'stop'      - Stop PMS
  2 - 'automatic' - database check, repair/optimize, and reindex in one step.
  3 - 'check'     - Perform integrity check of database
  4 - 'vacuum'    - Remove empty space from database
  5 - 'repair'    - Repair/Optimize  databases
  6 - 'reindex'   - Rebuild database database indexes
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky)
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive)
 10 - 'show'      - Show logfile
 11 - 'status'    - Report status of PMS (run-state and databases)
 12 - 'undo'      - Undo last successful command

 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 7

Starting PMS.
Started PMS

Select

  1 - 'stop'      - Stop PMS
  2 - 'automatic' - database check, repair/optimize, and reindex in one step.
  3 - 'check'     - Perform integrity check of database
  4 - 'vacuum'    - Remove empty space from database
  5 - 'repair'    - Repair/Optimize  databases
  6 - 'reindex'   - Rebuild database database indexes
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky)
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive)
 10 - 'show'      - Show logfile
 11 - 'status'    - Report status of PMS (run-state and databases)
 12 - 'undo'      - Undo last successful command

 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 11


Status report: Fri Jun  9 07:17:11 AM IST 2023
  PMS is stopped.
  Databases are OK.


Select

  1 - 'stop'      - Stop PMS
  2 - 'automatic' - database check, repair/optimize, and reindex in one step.
  3 - 'check'     - Perform integrity check of database
  4 - 'vacuum'    - Remove empty space from database
  5 - 'repair'    - Repair/Optimize  databases
  6 - 'reindex'   - Rebuild database database indexes
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky)
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive)
 10 - 'show'      - Show logfile
 11 - 'status'    - Report status of PMS (run-state and databases)
 12 - 'undo'      - Undo last successful command

 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 7

Starting PMS.
Started PMS

Select

  1 - 'stop'      - Stop PMS
  2 - 'automatic' - database check, repair/optimize, and reindex in one step.
  3 - 'check'     - Perform integrity check of database
  4 - 'vacuum'    - Remove empty space from database
  5 - 'repair'    - Repair/Optimize  databases
  6 - 'reindex'   - Rebuild database database indexes
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky)
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive)
 10 - 'show'      - Show logfile
 11 - 'status'    - Report status of PMS (run-state and databases)
 12 - 'undo'      - Undo last successful command

 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 11


Status report: Fri Jun  9 07:17:56 AM IST 2023
  PMS is stopped.
  Databases are OK.


Select

  1 - 'stop'      - Stop PMS
  2 - 'automatic' - database check, repair/optimize, and reindex in one step.
  3 - 'check'     - Perform integrity check of database
  4 - 'vacuum'    - Remove empty space from database
  5 - 'repair'    - Repair/Optimize  databases
  6 - 'reindex'   - Rebuild database database indexes
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky)
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive)
 10 - 'show'      - Show logfile
 11 - 'status'    - Report status of PMS (run-state and databases)
 12 - 'undo'      - Undo last successful command

 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : ^C

I’ve created the GHI and fixed the issue which requires running as root.
I’ve not yet published a new release. I have a few more things to put into it.

For you to get permissions working again, WITH PMS installed but stopped,

sudo bash
cd /var/packages/PlexMediaServer/shares/PlexMediaServer
chown -R PlexMediaServer:PlexMediaServer ./AppData &
find ./AppData -type d -exec chmod 755 {} \; &
find ./AppData -type f -exec chmod 644 {} \; &
wait

This is a forced reset of ownership and permissions of all files. It will take time to run.

The wait command tells the shell to wait for the 3 commands above it to complete before returning to the command line prompt.

The drives will be busy :slight_smile:

When it completes, PMS ownership will be restored

Excellent Chuck, fully understand that and appreciate your efforts here. I will just keep an eye out for any updates. Thank you.

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