Hi @ChuckPa - thanks for your script. I found it via a Reddit post & started to run it (Windows ps1 version 1.01.01) as my database had filled up my drive overnight
I only just got around to reading the Plex forum, specifically this one:
Where it states that the AUTO function might need 3 x the database size to run - I don’t have that much free space
What are my options now that the script is running? Can I stop it or is that going to cause problems?
This is the quick-fix to get you running while the official takes care of the root problem.
There is a new command (temporary) DEFLATE
It will remove 100 million records per block until done
It requires no additional disk space to run. (for those where PMS can’t run)
Data is protected by a Transaction / Commit block.
Below, 31 GB is reduced to 216 MB in 13 minutes on an i9-12900 with USB SSD
Here is my console output
[chuck@lizum databases.2025.05.17.2124]$ time sudo ./DBRepair.sh --sqlite /usr/lib/plexmediaserver --databases "$(pwd)" deflate
Database Repair Utility for Plex Media Server (User Defined)
Version v1.11.02
[2025-05-30 16.09.09] PlexSQLite = '/usr/lib/plexmediaserver/Plex SQLite'
[2025-05-30 16.09.09] Databases = '/usb/plex/PMS-save/Plug-in Support/Databases/databases.2025.05.17'
[2025-05-30 16.09.09] This command operates directly on your existing PMS DB.
[2025-05-30 16.09.09] There are no backups however the DB is protected by transaction blocking.
[2025-05-30 16.09.09] DO NOT INTERRUPT once started but you can if you must (It will resume where it left off).
[2025-05-30 16.09.09]
[2025-05-30 16.09.09] Removing - block 1
[2025-05-30 16.11.37] Removing - block 2
[2025-05-30 16.14.03] Removing - block 3
[2025-05-30 16.16.23] Removing - block 4
[2025-05-30 16.18.52] Removing - block 5
[2025-05-30 16.21.05] Removing - block 6
[2025-05-30 16.22.40] Removed 571458809 records.
[2025-05-30 16.22.40] Vacuuming DB to reclaim working space.
[2025-05-30 16.22.43] Initial Database size = 33120 MB
[2025-05-30 16.22.43] Final Database size = 216 MB
real 13m34.032s
user 0m0.003s
sys 0m0.006s
[chuck@lizum databases.2025.05.17.2125]$
Here is the tar ball. This will go to GitHub as soon as there is confirmed confidence.
Looks like pidof doesn’t exist on MacOS, and then it locked it so when I try to re-run it it also fails.
Databases sudo ./DBRepair.sh --sqlite /Applications/Plex\ Media\ Server.app/Contents/MacOS/Plex\ SQLite --databases "$(pwd)" deflate
stat: illegal option -- c
usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
stat: illegal option -- c
usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
Database Repair Utility for Plex Media Server (User Defined)
Version v1.11.02
[2025-05-30 15.26.12] PlexSQLite = '/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite'
[2025-05-30 15.26.12] Databases = '/Volumes/NVMe_Workspace/Plex Application Support/Plex Media Server/Plug-in Support/Databases'
[2025-05-30 15.26.12] This command operates directly on your existing PMS DB.
[2025-05-30 15.26.12] There are no backups however the DB is protected by transaction blocking.
[2025-05-30 15.26.12] DO NOT INTERRUPT once started but you can if you must (It will resume where it left off).
[2025-05-30 15.26.12]
./DBRepair.sh: line 1545: pidof: command not found
Error: in prepare, database is locked (5)
stat: illegal option -- c
usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
[2025-05-30 15.26.12] Removing - block 1
Error: in prepare, database is locked (5)
./DBRepair.sh: line 1776: 0 + : syntax error: operand expected (error token is " ")
Looks like it’s hung at the moment. Been 15+ minutes with no output:
stat: illegal option -- c
usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
stat: illegal option -- c
usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
Database Repair Utility for Plex Media Server (User Defined)
Version v1.11.02
[2025-05-30 15.29.51] PlexSQLite = '/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite'
[2025-05-30 15.29.51] Databases = '/Volumes/NVMe_Workspace/Plex Application Support/Plex Media Server/Plug-in Support/Databases'
[2025-05-30 15.29.51] This command operates directly on your existing PMS DB.
[2025-05-30 15.29.51] There are no backups however the DB is protected by transaction blocking.
[2025-05-30 15.29.51] DO NOT INTERRUPT once started but you can if you must (It will resume where it left off).
[2025-05-30 15.29.51]
Activity monitor shows the SQLite still reading/writing data so going to leave it be for now and check back.
When Manual Mode is invoked, no host detection is performed.
In Manual Mode, all commands are based on Linux, not Unix (MacOS).
If you run the tool normally:
It will detect MacOS and configure commands for the MacOS host
It will still compute free available based on your suggestion / PR to use $DBDIR. This means it will resolve through your symlink to where the databases are actually stored.
I added transaction protection to all database actions.
– anything not completed is immediately undone by SQLite
Deflate or 911 – both work.
Look at my output.
That’s an i9 - 12900 (Dragon Canyon) NUC with NVMe SSD. It reads 1GB/sec.
The biggest load was being CPU-bound (1 core) for that 2.5 minutes per block.
Looks like some sort of bug on macOS for the output, but the new DB is working and much much smaller. Took about an hour.
Ok to begin deflating the databases? (Y/N) ? y
Removing - block 1
Removed 0 records.
Vacuuming DB to reclaim working space.
Initial Database size = 107368 MB
Final Database size = 469 MB
[chuck@lizum databases.2025.05.17.2005]$ sudo time ~/git/chuck/DBRepair/DBRepair.sh --sqlite /usr/lib/plexmediaserver --databases "$(pwd)" deflate
Database Repair Utility for Plex Media Server (User Defined)
Version v1.11.02
[2025-05-30 19.26.59] PlexSQLite = '/usr/lib/plexmediaserver/Plex SQLite'
[2025-05-30 19.26.59] Databases = '/usb/plex/PMS-save/Plug-in Support/Databases/databases.2025.05.17'
[2025-05-30 19.26.59] This command operates directly on your existing PMS DB.
[2025-05-30 19.26.59] There are no backups however the DB is protected by transaction blocking.
[2025-05-30 19.26.59] DO NOT INTERRUPT once started but you can if you must (It will resume where it left off).
[2025-05-30 19.26.59]
[2025-05-30 19.26.59] Removing - block 1
[2025-05-30 19.29.33] Removing - block 2
[2025-05-30 19.32.01] Removing - block 3
[2025-05-30 19.34.23] Removing - block 4
[2025-05-30 19.36.56] Removing - block 5
[2025-05-30 19.39.09] Removing - block 6
[2025-05-30 19.40.44] Removed 571458809 records.
[2025-05-30 19.40.44] Vacuuming DB to reclaim working space.
[2025-05-30 19.40.47] Initial Database size = 33120 MB
[2025-05-30 19.40.47] Final Database size = 216 MB
737.98user 32.98system 13:47.81elapsed 93%CPU (0avgtext+0avgdata 37384maxresident)k
52100992inputs+89108072outputs (0major+1756763minor)pagefaults 0swaps
[chuck@lizum databases.2025.05.17.2006]$
Now to figure out if I messed up the shell math syntax on MacOS