# DBRepair development

**URL:** <https://forums.plex.tv/t/dbrepair-development/822684>\
**Category:** Apps & Creations\
**Created:** [December 14, 2022, 3:57am UTC](https://forums.plex.tv/t/dbrepair-development/822684 "2022-12-14T03:57:23Z")\
**Posts on this page:** 20\
**Page:** 36

<div class="post-metadata">

**Author:** ![adampope](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/adampope/32/209663_2.png) [@adampope](https://forums.plex.tv/u/adampope)\
**Post date:** [June 22, 2025, 10:18am UTC](https://forums.plex.tv/t/dbrepair-development/822684/763 "2025-06-22T10:18:10Z")

</div>

# Done! Worked a charm, took 5m, reducing main DB size by another 5%…

2025-06-22 11.05.05 - Session start: Host is Synology (DSM 7)  
2025-06-22 11.05.17 - Stop - PASS  
2025-06-22 11.05.24 - Auto - START  
2025-06-22 11.05.37 - Check - Check com.plexapp.plugins.library.db - PASS  
2025-06-22 11.05.44 - Check - Check com.plexapp.plugins.library.blobs.db - PASS  
2025-06-22 11.05.44 - Check - PASS  
2025-06-22 11.06.57 - Repair - Export databases - PASS  
2025-06-22 11.07.47 - Repair - Import - PASS  
2025-06-22 11.07.55 - Repair - Verify main database - PASS (Size: 404MB/379MB).  
2025-06-22 11.07.56 - Repair - Verify blobs database - PASS (Size: 288MB/311MB).  
2025-06-22 11.07.56 - Repair - Making repaired databases active  
2025-06-22 11.07.56 - Repair - Move files - PASS  
2025-06-22 11.07.56 - Repair - PASS  
2025-06-22 11.07.56 - Repair - PASS  
2025-06-22 11.07.56 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS  
2025-06-22 11.07.57 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS  
2025-06-22 11.07.57 - Reindex - MakeBackup - PASS  
2025-06-22 11.08.08 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS  
2025-06-22 11.08.09 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS  
2025-06-22 11.08.09 - Reindex - PASS  
2025-06-22 11.08.09 - Reindex - PASS  
2025-06-22 11.08.09 - Auto - COMPLETED  
2025-06-22 11.08.34 - Start - PASS  
2025-06-22 11.09.45 - Exit - Delete temp files.  
2025-06-22 11.09.46 - Session end. Sun Jun 22 11:09:46 AM IST 2025  
2025-06-22 11.09.46 - ============================================================

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [June 22, 2025, 4:08pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/764 "2025-06-22T16:08:08Z")

</div>

Start / Stop are a separate mechanism.

A user might want to auto repair then include (merge) watch history.  
“Auto” isn’t at the sophistication (automation) level I want.

It was created with the plan to have a DBRepair.conf (config) file.  
None of that ever worked as intended but by that time, the popularity mandated I keep the commands as they were.

---

<div class="post-metadata">

**Author:** ![Fluamsler](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fluamsler/32/163641_2.png) [@Fluamsler](https://forums.plex.tv/u/Fluamsler)\
**Post date:** [July 26, 2025, 10:20pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/765 "2025-07-26T22:20:17Z")

</div>

@ChuckPa  
Not that I need the script now but maybe you should add another information to the tutorial on GitHub. 😉

On the bottom of the tutorial by the chapter  
**DSM 7 - Step 2 - Run DBRepair as the designated username** you write:  
_make sure it is executable._

I think it could be helpful to add a short tutorial **how** you make it executable (what steps would be necessary here) and/or how to check if it is. (I personally would have no clue how to do this) 🤣

---

<div class="post-metadata">

**Author:** ![Insomnic\_1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/insomnic_1/32/215416_2.png) [@Insomnic\_1](https://forums.plex.tv/u/Insomnic_1)\
**Post date:** [July 27, 2025, 12:11am UTC](https://forums.plex.tv/t/dbrepair-development/822684/766 "2025-07-27T00:11:46Z")

</div>

> [@Fluamsler](#):
>
> I think it could be helpful to add a short tutorial **how** you make it executable

The examples for the different environments show the command to do it.

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [July 27, 2025, 12:55am UTC](https://forums.plex.tv/t/dbrepair-development/822684/767 "2025-07-27T00:55:18Z")

</div>

In all cases on Unix & Linux hosts, as I show the commands.  
Granted it takes a few extra steps if you are afraid of using SSH / Putty into the Syno.

The general form is always:

```auto
    sudo bash <---- Elevate to administrator (root) privilege) 
    cd /path/to/DBRepair.tar_dir <---- change to directory where DBRepair.tar is
    tar xf DBRepair-x.y.z.tar.gz <---- Extract the tar file to get all the pieces out
    cd DBRepair-x.y.z <--- Get into the subdirectory where DBRepair.sh is
    chmod +x DBRepair.sh <--- Give it execute permission
    ./DBRepair.sh stop auto start exit <--- Run it

```

---

<div class="post-metadata">

**Author:** ![Fluamsler](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fluamsler/32/163641_2.png) [@Fluamsler](https://forums.plex.tv/u/Fluamsler)\
**Post date:** [July 27, 2025, 1:43am UTC](https://forums.plex.tv/t/dbrepair-development/822684/768 "2025-07-27T01:43:03Z")

</div>

Got it!  
Sorry, I was a bit confused first because I thought “executable” has something to do with the file permission checkboxes on DSM. But this make sense now. 🙂

Thanks a lot guys for clarifying this!

---

<div class="post-metadata">

**Author:** ![ClassicUA](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/classicua/32/343097_2.png) [@ClassicUA](https://forums.plex.tv/u/ClassicUA)\
**Post date:** [August 14, 2025, 8:05pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/769 "2025-08-14T20:05:56Z")

</div>

Hi.

For some reason, prune isn’t working for me.

The script is located in volume1, PlexMediaServer on volume2.

The prune command doesn’t see the files.

DSM 7.2.2-72806 Update 4

---

<div class="post-metadata">

**Author:** ![FordGuy61](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@FordGuy61](https://forums.plex.tv/u/FordGuy61)\
**Post date:** [August 14, 2025, 8:46pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/770 "2025-08-14T20:46:51Z")

</div>

> [@ClassicUA](#):
>
> The prune command doesn’t see the files.

Does it find the database files OK when you run auto, check, etc.?

Does it say “No files found to prune”?

That just means there were no files older than 30 days.

If it said something else, please copy the output to the thread.

  

Example: From my DS918+:

```auto
Enter command # -or- command name (4 char min) : prune

Counting how many files can be removed.
No files found to prune.

```

And from the log file (I ran prune twice):

```auto
2025-08-14 15.37.27 - ============================================================
2025-08-14 15.37.27 - Session start: Host is Synology (DSM 7)
2025-08-14 15.37.36 - Stop - PASS
2025-08-14 15.37.38 - Prune - START
2025-08-14 15.37.40 - Prune - PASS
2025-08-14 15.47.26 - Prune - START
2025-08-14 15.47.28 - Prune - PASS
==================================================================================

```

---

<div class="post-metadata">

**Author:** ![ClassicUA](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/classicua/32/343097_2.png) [@ClassicUA](https://forums.plex.tv/u/ClassicUA)\
**Post date:** [August 14, 2025, 9:35pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/771 "2025-08-14T21:35:01Z")

</div>

Everything is fine with the database.

The files were not deleted because they are less than 30 days old.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [August 15, 2025, 3:03am UTC](https://forums.plex.tv/t/dbrepair-development/822684/772 "2025-08-15T03:03:16Z")

</div>

See the README.md

```auto
Environment Variables

DBRepair now supports the use of environment variables to allow customization of some operations.

WARNING: Use of these variables may adverse impact PMS operation or performance. USE WITH CAUTION.

DBREPAIR_CACHEAGE - Specify the maximum age for PhotoTrancoder Cache images to be retained
Default DBREPAIR_CACHEAGE is set at 30 days.

You may override this by setting DBREPAIR_CACHEAGE=N, where N is the number of days worth of cache image you wish to retain.

When using interactively, DBRepair will prompt you to confirm OK to remove and show you the cache age

Example: export DBREPAIR_CACHEAGE=20

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

Counting how many files are more than 20 days old.
OK to prune 4497 files? (Y/N) ?

```

---

<div class="post-metadata">

**Author:** ![ClassicUA](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/classicua/32/343097_2.png) [@ClassicUA](https://forums.plex.tv/u/ClassicUA)\
**Post date:** [August 23, 2025, 6:30pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/773 "2025-08-23T18:30:14Z")

</div>

Hi.

Is it possible to attach [https://textual.textualize.io/](https://textual.textualize.io/) to DBRepair so that you don’t have to log in via SSH?

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [August 23, 2025, 7:06pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/774 "2025-08-23T19:06:39Z")

</div>

@ClassicUA

That would unfortunately be a no.

The script runs native on the target host with no other dependencies other than an installed Plex server (Plex SQLite)

Adding dependencies violates the design premise

If you’re familiar with SSH:

1. ssh-copy-id username@hostname
2. ssh user@hostname sudo /path/to/dbrepair.sh stop auto start exit

No interactive login required  
You will need to add ‘user’ to the /etc/sudoers

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [September 12, 2025, 11:28pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/775 "2025-09-12T23:28:24Z")

</div>

### ALL:

Due to recent events, I’ve had to dust off some other code and tweak it a bit.

Might I impose and ask for some QA help to confirm it works as expected on the various hosts and docker containers?

v1.11.0

[UserCredentialReset.tar](https://forums.plex.tv/uploads/short-url/eTFm4NvmV6QrefbgCUHZNiDkZbr.tar) (30 KB)

---

<div class="post-metadata">

**Author:** ![FordGuy61](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@FordGuy61](https://forums.plex.tv/u/FordGuy61)\
**Post date:** [September 13, 2025, 12:11am UTC](https://forums.plex.tv/t/dbrepair-development/822684/776 "2025-09-13T00:11:18Z")

</div>

Works fine on my N100/Ubuntu 24.04 box.  
I used Settings → server\_name → General + Remove to remove the server from my account.  
I then ran the script and it reclaimed the server.

> **User Credential Reset output**
>
> ```auto
> $ sudo ./UserCredentialReset.sh claim-JJ7HzpzsNZgadY4Mxu9-
> 
> User credential reset & reclaim tool for Plex Media Server (Linux) (Ubuntu 24.04.3 LTS)
> (Version: v1.11.0)
> 
> This utility will reset the server's credentials.
> It will next reclaim the server for you using a Plex Claim token you provide from https://plex.tv/claim
> 
> Using given claim token: 'claim-JJ7HzpzsNZgadY4Mxu9-'
> 
> Stopping PMS
> Clearing Preferences.xml
> Getting new credentials from Plex.tv
> Claim completed without errors.
> Username: FordGuy61
> Email: <redacted>
> 
> Starting PMS
> Complete.
> $
> 
> ```

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [September 13, 2025, 2:44am UTC](https://forums.plex.tv/t/dbrepair-development/822684/777 "2025-09-13T02:44:20Z")

</div>

THank you.

I did find a bug (typo) — fixed it.

UserCredentialReset is now published v1.11.0

---

<div class="post-metadata">

**Author:** ![nibbles](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/nibbles/32/150497_2.png) [@nibbles](https://forums.plex.tv/u/nibbles)\
**Post date:** [September 14, 2025, 4:27am UTC](https://forums.plex.tv/t/dbrepair-development/822684/778 "2025-09-14T04:27:51Z")

</div>

I took a look at `UserCredentialReset.sh`

Although the README mentions MacOS might have been supported through manual location of the `Preferences.xml` file, it won’t work for a modern MacOS which has too many unique behaviors, different command arguments for `stat` and `sed`, and no `Preferences.xml` like we have on Linux.

It looks like PMS stores its config for MacOS in  
`com.plexapp.plexmediaserver.plist`  
that’s no longer human readable.  
The user has to modify it using the `Defaults(1)` command.

I found a GUI client works well for resetting as described in the Plex Support docs, but I wanted to say nice job on the shell utility. It was a pleasure to read, and have a nice weekend 🙂

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [September 14, 2025, 5:20am UTC](https://forums.plex.tv/t/dbrepair-development/822684/779 "2025-09-14T05:20:03Z")

</div>

I’ll make certain to remove MacOS. It runs as your username.

AFAIK, no claiming is required

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [October 4, 2025, 6:24am UTC](https://forums.plex.tv/t/dbrepair-development/822684/780 "2025-10-04T06:24:44Z")

</div>

### Folks,

Since “DeflateGate” is still lingering…  
and I’ve learned what’s needed for bandwidth\_statistics to continue to function,

I’ve prototyped DBRepair v1.12.00

The text it current outputs feels “off”  
(Auto & Deflate should, imho, be mostly similar as they are 3-step processes)

I need help with how to fix the working. May I ask your input please ?

```auto
 21 - 'prune' - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 22 - 'purge' - Remove unused temp files.
 23 - 'deflate' - Deflate a bloated PMS main database.
 42 - 'ignore' - Ignore duplicate/constraint errors.

 88 - 'update' - Check for updates.
 98 - 'quit' - Quit immediately. Keep all temporary files.
 99 - 'exit' - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 23
 
Automatic Check and Deflate started.

Checking the PMS databases

Check complete. PMS main database is OK.
Check complete. PMS blobs database is OK.

Backup current databases with '-BACKUP-2025-10-04_02.15.41' timestamp.
Starting Deflate. (There will be no output until complete.)
PMS main database successfully repaired.
Reducing main database size.
PMS main database size reduced.
Verifying PMS main database.
Verification complete. PMS main database is OK. New size = 206 MB
PMS main database deflate completed.
Saving current main database with '-BLOATED-2025-10-04_02.15.41'
Making deflated database active
Deflate complete. Please check your library settings and contents for completeness.
Deflate successful.
Recommend running Auto next to complete optimization of new database.

Select

  1 - 'stop' - (Not available. Stop manually.)
  2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.

```

This example did a full check of a 31 GB DB, and reduced it in 12 minutes.

---

<div class="post-metadata">

**Author:** ![nibbles](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/nibbles/32/150497_2.png) [@nibbles](https://forums.plex.tv/u/nibbles)\
**Post date:** [October 4, 2025, 6:41am UTC](https://forums.plex.tv/t/dbrepair-development/822684/781 "2025-10-04T06:41:26Z")

</div>

> [@ChuckPa](#):
>
> `Automatic Check and Deflate started.`

You might leave out the Automatic part, e.g.

```auto
Deflate started.

Checking the PMS database

```

I’d be interested to know the starting DB size,  
the ending DB size, and the percentage reduction, e.g.

```auto
PMS main database size reduced from 10 GB to 206 MB (98%).

```

Then Automatic would continue to mean the same thing people are used to.  
Thanks for working on it.

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [October 4, 2025, 5:12pm UTC](https://forums.plex.tv/t/dbrepair-development/822684/782 "2025-10-04T17:12:13Z")

</div>

@nibbles

Regarding shell math.

1. I’ve flipped it around. Every test I ran was a “99%” reduction which was useless.
2. Simple multiplier seems to work better

```auto
[chuck@lizum databases.2025.05.17.2037]$ SizeStart=135000
[chuck@lizum databases.2025.05.17.2038]$ SizeFinish=207
[chuck@lizum databases.2025.05.17.2039]$ SizeReduce=$(($SizeStart / $SizeFinish))
[chuck@lizum databases.2025.05.17.2040]$ echo Start=$SizeStart MB, Finish=$SizeFinish MB, Reduction=$SizeReduce \%
Start=135000 MB, Finish=207 MB, Reduction=652 %
[chuck@lizum databases.2025.05.17.2041]$

```

This ratio expresses multiples of the Finish size needed to get to Start size.

Does this work better?

* * *

I’m fixing the comments throughout the new function. Almost there.

[Previous page](https://forums.plex.tv/t/dbrepair-development/822684.md?page=35)

[Next page](https://forums.plex.tv/t/dbrepair-development/822684.md?page=37)
