On Windows 10 here: If the mentioned script basically defragments the files in the database, I wonder if simply restoring an image backup of its partition wouldn’t work just as well? Is there something more it does (other than the “Optimize” button in PMS? Maybe all I need it the Vacuuming command?
TLDR: I store Plex’s database location in its own partition on a different SSD than Windows, or the media storage drives. I make regular, compressed, image-backups of that partition weekly, with Aomei Backupper. When it restores a partition there is 0% fragmentation because it reformats it and extracts the files contigiously, with no recycle bin. But it does backup the cache folder. My partition is also only 30% full.