Auto runs ChuckPa / DBRepair; A db repair script to fix PLEX db file
10K+
⚠️ This container modifies your Plex SQLite database.
Always ensure you have verified, working backups before proceeding.
One-shot Plex database maintenance for Docker and Unraid Community Applications.
Docker Hub · GitHub source · Unraid CA template · Support thread
YOU ARE RESPONSIBLE FOR YOUR OWN DATA. This container can modify or rebuild Plex databases. Keep an independent, verified, restorable backup of your Plex appdata before running maintenance on a production library. The built-in backup is an additional safeguard, not a replacement for an external backup.
This image bundles ChuckPa DBRepair v26.10.00, the compiled upstream utility. It does not run the legacy DBRepair.sh or the old custom SQLite/FTS code.
/var/run/docker.sock (no nested Docker daemon).PLEX_CONTAINER_NAME./tmp/plex-dbrepair-runner and executes it with docker exec.DBRepair stop; if necessary and permitted, sends SIGTERM to the Plex server process. The Plex container must remain running for maintenance through docker exec.ENABLE_BACKUPS=true (except prune), executes the requested operation, and by default restarts the Plex Docker container after a successful run.No Plex appdata bind mount is required on the repair container. PLEX_MOUNT=/config refers to the internal path within the target Plex container, not a volume mapping for DBRepair.
This implementation has no offline repair fallback if the target Plex container exits or the Plex process cannot remain stopped.
Install using the Unraid plexrepair.xml template.
For most users, the defaults are sufficient:
DBREPAIR_MODE=automaticPLEX_CONTAINER_NAME=autoENABLE_BACKUPS=trueRESTART_PLEX=true/var/run/docker.sock/logsSet the DBRepair container restart policy to No. It is a one-shot maintenance job, not a continuously running service. Do not configure always or unless-stopped for the repair container.
The Plex server container must be running initially. DBRepair then stops its internal PMS process for maintenance. If several Plex installations are found, set PLEX_CONTAINER_NAME to the exact name shown by docker ps (for example plex).
Normally Plex's internal library root is /config/Library/Application Support/Plex Media Server. Advanced users with custom internal paths may change PLEX_MOUNT and PLEX_REL.
Security: Access to the Docker socket grants effective administrative control over the host. Install only images and scripts you trust. Docker's --privileged option is not required.
docker run --name plex-dbrepair-test \
--hostname plex-dbrepair-test \
--network bridge \
--restart no \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /mnt/user/appdata/plex-dbrepair-logs:/logs \
-e DBREPAIR_MODE=automatic \
-e PLEX_CONTAINER_NAME=auto \
-e PLEX_CONTAINER_MATCH=plex \
-e PLEX_MOUNT=/config \
-e PLEX_REL='Library/Application Support/Plex Media Server' \
-e ENABLE_BACKUPS=true \
-e ALLOW_PLEX_KILL=true \
-e RESTART_PLEX=true \
-e PRUNE_DAYS=30 \
-e DBREPAIR_TIMEOUT=7200 \
-e STOP_TIMEOUT=90 \
bmmbmm01/plex-dbrepair:latest
The /mnt/user/appdata/... path above is an Unraid example; replace it with an appropriate host directory on other systems, such as /VMs/docker/plex-dbrepair-logs on a PVE/Debian host.
To repeat a run, first remove the stopped repair container, not the Plex container:
docker rm plex-dbrepair-test
Useful commands after a run (before removing the repair container):
docker logs plex-dbrepair-test
docker inspect plex-dbrepair-test --format '{{.State.ExitCode}}'
docker ps --filter name=plex
Check that the Plex application is responding after the repair; an exit code of 0 alone does not prove all media services are healthy.
DBREPAIR_MODE | Upstream command | Behavior |
|---|---|---|
automatic (default) | auto | Upstream automatic checks/maintenance. Does not guarantee VACUUM and REINDEX on every run. |
check | check | Check Main and Blobs database integrity. |
vacuum | vacuum | VACUUM databases and verify the resulting files. |
repair | repair | Rebuild databases, including schema, FTS tables, triggers, records, and indexes. |
reindex | reindex | Rebuild database indexes and verify results. |
deflate | deflate | Check bloat and compact when DBRepair determines it is necessary. |
prune | prune | Remove old PhotoTranscoder cache files according to PRUNE_DAYS. |
Unknown mode strings fall back to automatic. Errors in detection, shutdown, backup, or maintenance do not trigger an automatic repair fallback. Legacy ftscheck maps to check and ftsrepair maps to reindex. manual is rejected by this one-shot entrypoint.
| Variable | Default | Description |
|---|---|---|
DBREPAIR_MODE | automatic | Maintenance operation from the table above. |
PLEX_CONTAINER_NAME | auto | Auto-detect or use an exact Docker container name (not an image name). |
PLEX_CONTAINER_MATCH | plex | Name substring for auto-detection; Plex image names are also considered. |
PLEX_MOUNT | /config | Plex configuration mount inside the target Plex container. |
PLEX_REL | Library/Application Support/Plex Media Server | Relative path from PLEX_MOUNT to the Plex Media Server directory. |
ENABLE_BACKUPS | true | Create cold archive before maintenance, except in prune mode. |
ALLOW_PLEX_KILL | true | Permit SIGTERM of the PMS process if upstream stop does not stop it. |
RESTART_PLEX | true | Restart the Plex Docker container after successful maintenance. Maintenance failure/timeout does not auto-restart it. |
PRUNE_DAYS | 30 | PhotoTranscoder age threshold for prune; valid range 1–999. |
DBREPAIR_TIMEOUT | 7200 | Maximum DBRepair maintenance execution, seconds. |
STOP_TIMEOUT | 90 | Wait for Plex Media Server process to exit, seconds. |
LOG_DIR | /logs | Log location inside DBRepair; bind mount a persistent host folder. |
RESTART_FALLBACK | true | Permit Docker start if the target container exits during cleanup where cleanup is allowed. Not an offline repair mode. |
RESTORE_LAST_BACKUP | false | Unsupported if set to true; entrypoint aborts rather than selecting a backup automatically. |
EXCLUDE_CONTAINER_NAMES | dbrepair,plex-dbrepair | Internal discovery exclusions; generally leave unchanged. |
EXCLUDE_IMAGE_REGEX | plex-dbrepair | Internal repair-image discovery exclusion; generally leave unchanged. |
Legacy ENABLE_FTS_CHECK and ENABLE_FTS_REPAIR variables are no longer needed; the compiled upstream DBRepair utility manages compatible FTS operations itself.
When enabled, archives are created inside the target Plex configuration, not inside the repair container:
/config/Library/Application Support/Plex Media Server/DBRepair-Backups/dbrepair-pre-auto-YYYYMMDDTHHMMSSZ.tar.gz
Backups contain the Plug-in Support/Databases directory, including any present SQLite WAL/SHM files. The script creates the archive while Plex Media Server is stopped and checks that the archive can be listed. This is not the same as testing a full restore.
Backups are not automatically pruned; large Plex libraries need sufficient free space. Maintain your own independent backup strategy. The older RESTORE_LAST_BACKUP feature is not implemented in this rewrite; recovery requires deliberate backup selection and manual restore procedures.
If PMS restarts unexpectedly, its container exits, or DBRepair encounters a failure or timeout, the tool may exit without bringing Plex back online. In particular, a failure during active database maintenance intentionally avoids automatic restart. Inspect the persistent logs and database state before restarting Plex manually.
/tmp compatibilityThe current image stages its DBRepair executable at /tmp/plex-dbrepair-runner inside the Plex container. That directory must be writable, accessible via docker cp, and executable.
Custom Docker Compose tmpfs mappings of /tmp can cause problems, especially if the filesystem has the noexec mount option. Observed errors include:
Error: No such container:path: ...:/tmp/plex-dbrepair-runner
ERROR: Cannot copy DBRepair to Plex
permission denied
Check the target Plex mount options:
docker exec plex sh -c "grep ' /tmp ' /proc/mounts"
For example, this Compose configuration may be incompatible:
tmpfs:
- /tmp:size=1g,mode=1777
If you experience executable staging failures, the simplest supported approach is to disable the custom /tmp tmpfs mapping and recreate the Plex container, then rerun the repair. Removing a tmpfs mapping does not guarantee success if the replacement /tmp is also noexec or otherwise restricted. The current published image does not automatically fall back to /config.
An executable staging failure happens before database maintenance. Read the DBRepair container logs to confirm where it stopped.
LinuxServer Plex, disposable test library (PMS 1.43.4.10903, DBRepair 26.10.00):
| Mode | Observed result |
|---|---|
automatic | Database checks successful; no orphaned media items; exit 0. |
vacuum | Main and Blobs DB VACUUM and post-operation verification succeeded; exit 0. |
reindex | Main and Blobs indexes rebuilt and checked; exit 0. |
repair | Main and Blobs databases rebuilt, including FTS structures; exit 0. |
deflate | No deflation needed on the fresh library; exit 0. |
prune | Completed; no aged files present to remove; exit 0. |
PVE production LinuxServer Plex: Automatic mode completed integrity and orphan checks, created a cold backup, and reported a successful Docker restart and exit 0 after staging the executable in an alternate executable directory as a manual test workaround. The unmodified public image initially failed on that host because Plex's /tmp was tmpfs-mounted with noexec. This workaround is not included in the published image.
These tests do not establish successful recovery from an actually corrupted database, meaningful deflate compaction, deletion of real aged cache files, or compatibility with every Plex container or future Plex database schema. Binhex and Hotio remain unverified. Check upstream DBRepair releases for compatibility information.
DBRepair is developed by ChuckPa and remains proprietary software. Copyright © 2022–2026 ChuckPa. All rights reserved. The compiled DBRepair program is distributed under its own license, which requires express written permission for redistribution. A separate license on this Docker wrapper does not change the terms of the upstream executable.
The Dockerfile, entrypoint automation, documentation, and Unraid integration are independently maintained by bmartino1. Review this repository's LICENSE and any third-party notices for the wrapper's applicable terms. This is an independent community integration; it is not an official Plex or ChuckPa release.
Redistributors: Verify that your distribution of the bundled DBRepair executable is expressly authorized by ChuckPa. A link or attribution alone does not grant redistribution permission.
Content type
Image
Digest
sha256:3448447c4…
Size
133.8 MB
Last updated
8 days ago
docker pull bmmbmm01/plex-dbrepair