Maintenance and monitoring scripts for a Plex media server stack running on a Raspberry Pi (or any Linux box). Handles health checks, backups, library reporting, media analysis, and scheduled maintenance.
| Service | What it does | Schedule | Links |
|---|---|---|---|
| Plex | Media streaming server | Always running | Support |
| Kometa | Metadata, collections, and overlay management for Plex | Daily at 05:00 (internal scheduler) | Wiki |
| UMTK | Upcoming movies/TV shows + TV show status overlays for Kometa | Daily at 02:00 (Docker internal cron) | Docs |
| Floppy | Self-hosted media tracker | Always running (Docker) | GitHub |
| Simkl | External media tracker (cloud) | Always running (Plex webhook) | Docs |
| ImageMaid | Plex metadata image cleanup and DB optimization | Weekly Sundays at 07:00 (Docker internal) | GitHub |
| Radarr | Movie management and downloads | Always running (Docker) | |
| Sonarr | TV show management and downloads | Always running (Docker) | |
| Bazarr | Subtitle downloads | Always running (Docker) | |
| AURA | Artwork management via MediUX | Always running (Docker), AutoDownload daily at 04:00 | Docs |
The scripts monitor, maintain, and report on this stack. They don't replace any of these tools — they wrap around them to keep everything healthy and give you visibility into your library.
# 1. Clone the repo
git clone git@github.com:itsFelixH/media-server-scripts.git ~/kometa/scripts
cd ~/kometa/scripts
# 2. Create your config from the template
cp config.yml.template config.yml
# 3. Fill in your values (see Configuration section below)
nano config.yml
# 4. Test a script
bash healthcheck.sh- OS: Linux (tested on Raspberry Pi OS / Debian)
- Shell: Bash
- Core tools:
jq,curl - Media analysis:
ffprobe(from ffmpeg) - Metadata audit:
python3,python3-yaml - Docker: For container management (Kometa, UMTK, ImageMaid, Radarr, Sonarr, Bazarr, etc.)
- systemd: For service monitoring (Plex)
UMTK generates the overlay files inside its own container, so the jobs around it are
ordered deliberately — Kometa aborts a run when a referenced overlay file is missing or
parses to an empty overlays: block:
| Time (UTC) | Job | Why it matters |
|---|---|---|
| 01:00 | umtk container (CRON=0 2 * * *, TZ=Europe/Berlin, ~6 s runtime) |
Writes ~/UMTK/kometa/*_OVERLAYS.yml incl. the TSSK label.not filters |
| 02:30 | fix-umtk-overlays.sh (cron) |
Rewrites empty placeholders, strips the undefined RequestNeeded label filter |
| 04:00 | kometa container (05:00 Europe/Berlin) |
Consumes the repaired overlays |
healthcheck.sh (every 30 min) is the safety net: it re-runs the repair whenever an
overlay file would not load, so a missed 02:30 run heals within half an hour.
| Script | Purpose | Schedule |
|---|---|---|
healthcheck.sh |
Monitor services, disk, memory, temperature, APIs | Every 30 min |
piboard-data.sh |
PiBoard data (system stats, services, last runs, network) | Every 1 min |
maintenance.sh |
System updates, Docker updates, Docker prune, log rotation, diagnostics | Mondays 06:00 |
backup.sh |
Archive all configs to media drive | Sundays 01:00 |
archive-reports.sh |
Copy changed reports to archive with date stamps | Daily 05:30 |
library-catalog.sh |
Snapshot library contents with diff tracking | Sundays 01:30 |
metadata-audit.sh |
Audit Plex artwork health & AURA/MediUX set coverage | Sundays 02:00 |
encode-queue.sh |
Find re-encoding candidates | 1st of month |
episode-gaps.sh |
Find TV shows with missing episodes vs TMDB | Sundays 03:00 |
storage-report.sh |
Disk usage breakdown by folder/codec/resolution (both libraries) | 28th of month |
plex-vs-arrs.sh |
Compare Plex library against Radarr/Sonarr | Sundays 02:30 |
fix-umtk-overlays.sh |
Rewrite empty UMTK overlay placeholders and drop undefined label filters so Kometa can load them | Daily 02:30 |
media-analyzer.sh |
Filter/analyze video files by codec, resolution, size | Manual |
runkometa.sh |
Interactive Kometa runner with library/mode selection | Manual |
piboard-api.py |
PiBoard action button API server (port 5052) | Always running (systemd) |
All scripts support -h/--help and --no-discord.
Scripts with terminal output support -q/--quiet for cron use.
healthcheck.sh — system & stack monitoring
Monitors system resources and service health. Runs silently, logs output, and sends Discord alerts on failures.
- Services: Plex (
plexmediaserver), Kometa, UMTK, ImageMaid, Floppy, PiBoard, Radarr, Sonarr, Bazarr, AURA - APIs: Plex, Radarr, Sonarr, Bazarr, UMTK
- Disk: Mount check (
/mnt/Media), disk usage percentage - Hardware: CPU temperature (Raspberry Pi
vcgencmdor/sys/class/thermal/), RAM usage - Network: Internet connectivity ping
- Containers: running/health state with auto-restart, plus restarts since the previous check (baseline in
logs/healthcheck/.container-restart-counts) so a single past crash loop does not warn forever - UMTK overlays: every
/umtk/*.ymlreferenced by the Kometa config exists, and no*_OVERLAYS.ymlis empty or has an emptyoverlays:block (overlays: {},overlays: [], bare key, comment-only) — repaired on the spot viafix-umtk-overlays.sh - Maintenance: Days since last
maintenance.shrun
- Log:
logs/healthcheck/healthcheck_YYYYMMDD.log - Alert: Discord
notifications.errorwebhook on service failure or high disk/temp
piboard-data.sh — collect PiBoard status metrics
Collects system statistics, docker container status, service health, network metrics, and script last-run info every minute for the PiBoard dashboard.
- Output JSON:
~/docker/piboard/data/system-status.json
piboard-api.py — PiBoard action button API server
Python API backend running on port 5052 as a systemd user service (piboard-api.service). Proxied via PiBoard Nginx at /api/actions/. Listens for trigger requests from the PiBoard frontend dashboard to run scripts and execute homelab automation actions.
| Method | Route | Description |
|---|---|---|
GET |
/api/actions/health |
Healthcheck and service status |
GET |
/api/actions/jobs |
List recent background task jobs |
GET |
/api/actions/jobs/{id} |
Poll status and log output of a specific job |
POST |
/api/actions/run |
Trigger script execution (`{"task": "kometa" |
POST |
/api/actions/aura/link |
1-click MediUX Set Linker (`{"setId": "...", "ratingKey": "...", "title": "...", "mediaType": "movie" |
POST |
/api/actions/job/{id}/kill |
1-Click Cancel / Terminate running background job (process group SIGTERM -> SIGKILL) |
POST |
/api/actions/run/imagemaid-run |
Run ImageMaid image bloat cleanup & PhotoTranscoder cache prune |
POST |
/api/actions/run/docker-prune |
Safe Docker prune (stopped containers, unused networks, dangling images) |
maintenance.sh — system update & cleanup
Weekly system maintenance script. Runs package updates, cleans Docker, rotates logs, validates configs, and generates a diagnostic report.
- Package updates (
apt-get update && apt-get upgrade) - Docker cleanup (
docker image prune,docker container prune) - Config validation (YAML syntax check on Kometa, UMTK configs)
- Log rotation (compresses old logs, removes logs older than 30 days)
- Disk space check
- Sends summary notification to Discord
--scheduled— Run mode for cron (sends Discord notification on success/failure)--interactive— Interactive mode with confirmation prompts
backup.sh — configuration backup
Creates a zip archive of all critical configuration files and saves it to the media drive. Keeps the last 5 backups.
~/kometa/config/~/UMTK/config/~/ImageMaid/config/~/docker/~/.config/systemd/user/
- Archive:
/mnt/Media/backups/<hostname>-backup-YYYYMMDD.zip
archive-reports.sh — report archiving
Daily report archiving script. Checks for modified JSON/MD reports in reports/ and archives date-stamped copies to /mnt/Media/reports/.
fix-umtk-overlays.sh — UMTK overlay placeholder sanitiser
UMTK writes a comment-only *_OVERLAYS.yml when a category has no matching library items, and Kometa then refuses to load that file (YAML Error: overlays attribute is required). This script rewrites such placeholders (overlays: {}, overlays: [], bare overlays:, empty or comment-only files) with a valid overlay that matches nothing, so every overlay file referenced in ~/kometa/config/config.yml loads cleanly and applies no artwork. UMTK overwrites the placeholder as soon as a show matches.
It also strips the RequestNeeded label filter that TSSK hardcodes into the New Show overlays (label.not: Coming Soon, RequestNeeded). The label only exists when UMTK's label_request_needed option is enabled; while it is disabled, Kometa aborts those overlays with Plex Error: label: RequestNeeded not found.
tools.umtk_output (default ~/UMTK/kometa), tools.umtk (UMTK config dir, to read label_request_needed)
- Log:
logs/fix-umtk-overlays/fix-umtk-overlays_YYYYMMDD_HHMMSS.log
library-catalog.sh — Plex library snapshot & diff
Generates a complete catalog of movies and TV shows in Plex. Diffs against the previous run to detect added or removed content.
plex.url, plex.token
- Report:
reports/library-catalog.json(overwritten each run) - Baseline:
reports/library-catalog.baseline.json
metadata-audit.sh — Plex & AURA artwork audit
Audits artwork health across Plex and tracks AURA / MediUX poster and title card set coverage.
- Plex Artwork: Verifies poster/backdrop presence and TMDb/TVDb matching
- AURA / MediUX Sets: Tracks which movies and shows have active MediUX sets
- Title Cards & Season Posters: Detects TV shows with MediUX sets that lack episode title cards or season posters
- Collection Posters: Checks Plex Movie & TV collections for custom posters vs auto-generated collages
- Orphaned AURA Sets: Flags database entries for media removed from Plex
- Missing Sets: Generates direct clickable search links for unlinked movies/shows
- Report:
reports/metadata-audit.json
encode-queue.sh — find re-encoding candidates
Scans for non-HEVC/non-AV1 files and generates a prioritized re-encode list sorted by size. Estimates space savings. Does NOT perform any encoding.
media.*
- Report:
reports/encode-queue.json(overwritten each run)
./encode-queue.sh # Both libraries, files >1GB
./encode-queue.sh "/mnt/Media/Movies" # Movies only
./encode-queue.sh --min-size=2 --limit=20 # Only >2GB, top 20episode-gaps.sh — find TV shows with missing episodes
Compares Plex TV show episode counts against TMDB aired episodes. Reports shows where you have fewer episodes than have actually aired.
plex.url, plex.token, TMDb API key
- Report:
reports/episode-gaps.json
storage-report.sh — disk usage by folder, codec, resolution
Scans media directories and generates a detailed storage report.
- Report:
reports/storage-report.json
plex-vs-arrs.sh — compare Plex library against Radarr/Sonarr
Compares Plex library content against Radarr (movies) and Sonarr (TV shows) via their APIs. Finds items that exist in one system but not the other.
- Report:
reports/plex-vs-arrs.json
media-analyzer.sh — filter/analyze video files
Scans video files, probes each for codec and resolution, filters by mode.
runkometa.sh — interactive Kometa runner
Menu-driven interface for running Kometa inside its Docker container with different options.
# Every 1 minute: PiBoard data collector
* * * * * /home/felix/kometa/scripts/piboard-data.sh
# Health check (every 30 minutes)
*/30 * * * * bash ~/kometa/scripts/healthcheck.sh
# Weekly config backup (Sundays 01:00)
0 1 * * 0 bash ~/kometa/scripts/backup.sh
# Library catalog (Sundays 01:30)
30 1 * * 0 bash ~/kometa/scripts/library-catalog.sh --quiet
# Metadata audit (Sundays 02:00)
0 2 * * 0 bash ~/kometa/scripts/metadata-audit.sh --quiet
# Episode gaps (Sundays 03:00)
0 3 * * 0 bash ~/kometa/scripts/episode-gaps.sh --quiet
# Scheduled maintenance (Mondays 03:00)
0 3 * * 1 bash ~/kometa/scripts/maintenance.sh --scheduled
# Encode queue (1st of month 04:00)
0 4 1 * * bash ~/kometa/scripts/encode-queue.sh --quiet
# Storage report (28th of month 04:30)
30 4 28 * * bash ~/kometa/scripts/storage-report.sh --quiet
# Archive reports (daily 05:30)
30 5 * * * bash ~/kometa/scripts/archive-reports.sh --quiet
# Optional / Manual: Plex vs ARRs comparison
# 30 2 * * 0 bash ~/kometa/scripts/plex-vs-arrs.sh --quietThe Docker-based services have their own internal schedules:
| Service | Schedule | Managed by |
|---|---|---|
| Kometa | Daily at 05:00 | KOMETA_TIMES env var in compose |
| UMTK | Daily at 02:00 | Internal cron in container |
| AURA | AutoDownload daily at 04:00 | Internal cron in container |
| ImageMaid | Weekly Sundays at 07:00 | SCHEDULE in .env |
UMTK is also the generator for every TV collection Kometa ingests (/umtk/*.yml inside the Kometa
container): Coming Soon, Upcoming Seasons, New Season Started, Upcoming Episode,
Upcoming Finale, Season Finale, Final Episode, Returning Shows, New Shows. It runs at 02:00,
before the 05:00 Kometa run, so the YAMLs are always fresh. New Season Started
(recent_days_new_season_started: 90 in ~/UMTK/config/tssk_config.yml) lists shows whose newest
season — season 2 or later — premiered within the last 90 days and replaces the retired
recently-premiered.sh text-file list; brand-new shows are covered by TSSK New Shows.
Those TSSK collections are set to sync_mode: sync (UMTK ships append, which only ever adds — it
never shrinks a shelf), so every window stays accurate: after the switch Upcoming Seasons dropped from
32 accumulated items to the 8 currently in its 61-day window, Returning Shows 89 → 78, and the stale
New Shows shelf (44 items for a 7-day window, nothing added that week) was deleted.
All scripts share a single discord_notify function defined in config.sh. No per-script notification code needed.
~/kometa/scripts/
├── config.yml # Your config (gitignored, contains secrets)
├── config.yml.template # Template with full documentation
├── config.sh # Config loader + discord_notify function
├── healthcheck.sh
├── maintenance.sh
├── backup.sh
├── archive-reports.sh
├── runkometa.sh
├── library-catalog.sh
├── metadata-audit.sh
├── media-analyzer.sh
├── storage-report.sh
├── encode-queue.sh
├── episode-gaps.sh
├── plex-vs-arrs.sh # Compare Plex vs Radarr/Sonarr
├── piboard-data.sh # PiBoard system & service data collector
├── piboard-api.py # PiBoard action API sidecar server
├── docs/ # Known-issue / bug-report write-ups
│ └── kometa-plex-emoji-collection-removal-bug.md
├── logs/ # Per-script log subdirectories (gitignored)
│ ├── archive-reports/
│ ├── backup/
│ ├── healthcheck/
│ ├── maintenance/
│ └── ...
├── encode-exclude.txt # Encode queue exclusion patterns
└── reports/ # Generated JSON reports (gitignored)
-
Kometa could not remove items from emoji-named Plex collections — Plex
1.41.4.9463, Kometanightly. Runs loggedN Movie Removed/N Show Removed, but Plex kept the items, so collections such asMost Watched This Weekaccumulated stale members (includingComing Soonleaks). plexapi sends emoji as 4-byte UTF-8 in thecollection[].tag.tag-=remove parameter; Plex only matches CESU-8. Adds are unaffected (index-form rewrite).Mitigated 2026-11-24 — every collection name is now ASCII-only (no emoji in
config/movies.yml,config/tv.yml,~/UMTK/config/config.ymlor~/UMTK/config/tssk_config.yml) and the existing Plex collections were renamed in place, so their ratingKeys (and AURA artwork mappings) survived. Verified with a collections-only Kometa run: MoviesMost Watched This Week37 → 22 items, TV 44 → 30. Keep new collection names emoji-free; accented letters (Español,Deutsch) are fine — only astral-plane emoji break the tag match. Evidence, repro and probes:docs/kometa-plex-emoji-collection-removal-bug.md.