You Don’t Have to Go Home, But You Can’t Stay Here

Automate Plex Media Cleanup with Maintainerr and Docker

Have you seen hard drive prices lately? With an automated Plex stack, it is way too easy to fill up your NAS. You spin up Radarr, Sonarr, and Seerr to organize content, and six months later you are staring at 95% disk usage wondering who asked for a 4K remux of a movie nobody watched.

Buying another 16TB drive every time your pool gets tight is not a great long-term plan. A brand-new 16TB NAS drive runs around $600 these days, and even recertified enterprise drives are hovering around $330. Maintainerr solves that problem by acting as the janitor for your media server. It scans Plex for stale or unwatched content, puts it in a collection for a set number of days, and clears it out if nobody hits play.

Before You Begin

Make sure you have the following ready before deploying the container:

  • A host running Docker and Docker Compose (TrueNAS, Ubuntu, Debian, or similar).
  • An x86-64-v2 capable CPU if you are running inside a virtual machine (Proxmox or QEMU VMs using the legacy kvm64 CPU type will fail on Maintainerr’s image processing package, sharp, so switch the VM CPU type to host or x86-64-v2).
  • A running Plex server, plus Radarr and Sonarr if you want Maintainerr to unmonitor and delete files cleanly.
  • Tautulli and Seerr (optional, but helpful for multi-user watch history and resetting old requests).

Deploying the Maintainerr Container

Maintainerr stores its SQLite database and configuration inside /opt/data, so you will want to map a persistent directory on your host. Avoid running the container as root or using chmod 777 on that folder. Instead, set the user field to match the UID and GID that owns your appdata directory (for example, 1000:1000 on standard Linux, or 568:568 for the apps user on TrueNAS).

Note that older guides still point to ghcr.io/jorenn92/maintainerr:latest. The project moved to its own organization repository, so use ghcr.io/maintainerr/maintainerr:latest for current builds.

Create a docker-compose.yml file with the configuration below:

services:
  maintainerr:
    image: ghcr.io/maintainerr/maintainerr:latest
    container_name: maintainerr
    restart: unless-stopped
    user: "${PUID:-1000}:${PGID:-1000}"
    ports:
      - "6246:6246"
    volumes:
      - ${MAINTAINERR_DATA_DIR:-./data}:/opt/data
    environment:
      - TZ=${TZ:-America/New_York}
Code language: YAML (yaml)

Start the container in detached mode from the same directory:

docker compose up -d
Code language: Bash (bash)

Once the container is running, open http://<your-server-ip>:6246 in your browser to reach the Maintainerr web interface.

Connecting Your Media Stack

All of Maintainerr’s configuration happens in the web UI rather than static config files. You will need to connect your media server and *arr apps so Maintainerr can read watch history and manage deletions.

  1. Open Settings > Plex and sign in or enter your Plex server URL and token.
  2. Open Settings > Radarr and Settings > Sonarr, then enter the URL and API Key for each instance.
  3. If you run Tautulli or Seerr, add them under Settings > Tautulli and Settings > Seerr so Maintainerr can check multi-user watch history and clear out old requests when a file is removed.

Building Your First Cleanup Rule

Maintainerr follows a straightforward loop: rules match media, matched items land in a collection for a set number of days, and the final action runs when that timer expires. If someone watches an item while it is sitting in the collection, Maintainerr resets the clock.

  1. Go to Rules and click the + button to create a new rule.
  2. Give the rule a Name like Movies Leaving (Maintainerr uses this as the collection name in Plex too) and select your target Library, Radarr server, and Sonarr server.
  3. Set Radarr action (or Sonarr action) to Unmonitor for your first week of testing. Maintainerr deletes files permanently once an active deletion rule fires, and there is no undo. Testing with Unmonitor (or a 30-day window) lets you verify what your rule catches before anything disappears from disk.
  4. Set Take action after days to something like 14 or 30, and under Options, check Show on Plex home so the collection appears on the Plex Home screen.
  5. Add your rule conditions using AND logic, such as Plex > Date added older than 180 days and Plex > View count equal to 0. If you tag favorite movies with something like keep in Radarr or Plex, add an exclusion condition for that tag so classics never get touched.
  6. Save the rule and click Run to test it manually before turning on a schedule.

Starter Cleanup Rules

If you want a safe baseline before writing custom rules, these two cover most of the easy disk space wins without touching active shows or favorites. You can build them manually in the UI using the settings below, or click Import YAML in the rule builder to paste the conditions in directly. Note that YAML import only populates the rule conditions, so you will still set Name, Library, Radarr/Sonarr server, Radarr/Sonarr action, Take action after days, and Options in the form.

Stale or Unwatched Movies

This rule catches two groups of movies: unwatched movies added more than 180 days ago, and movies that have not been viewed in over 180 days. Using two rule sections with OR between them ensures the keep tag exclusion applies to both.

  • Name: Movies Leaving
  • Library: Movies
  • Take action after days: 14 to 30
  • Section 1 (AND):
    • Plex > Date added is older than 180 days
    • Plex > View count equals 0
    • Radarr > Tags does not contain keep (optional)
  • Section 2 (OR from Section 1, then AND):
    • Tautulli > Last view date is older than 180 days (or Plex > Last view date if you do not run Tautulli)
    • Radarr > Tags does not contain keep (optional)
  • Radarr action: Unmonitor and delete files, and enable Force delete Seerr request if Seerr is connected.

Here is the YAML for the movie rule conditions:

mediaType: MOVIES
rules:
  - "0":
      - firstValue: Plex.addDate
        action: BEFORE
        customValue:
          type: custom_days
          value: "180"
      - operator: AND
        firstValue: Plex.viewCount
        action: EQUALS
        customValue:
          type: number
          value: 0
      - operator: AND
        firstValue: Radarr.tags
        action: NOT_CONTAINS_PARTIAL
        customValue:
          type: text
          value: keep
  - "1":
      - operator: OR
        firstValue: Tautulli.lastViewedAt
        action: BEFORE
        customValue:
          type: custom_days
          value: "180"
      - operator: AND
        firstValue: Radarr.tags
        action: NOT_CONTAINS_PARTIAL
        customValue:
          type: text
          value: keep
Code language: YAML (yaml)

When you set up TV rules in Maintainerr, you can target Shows, Seasons, or Episodes (SHOWS, SEASONS, or EPISODES in YAML). The two examples below apply to the show as a whole.

Stale Unwatched TV Shows

  • Name: TV Leaving – Unwatched
  • Library: TV Shows
  • Target: Shows
  • Take action after days: 14 to 30
  • Conditions (AND):
    • Plex > Date added is older than 180 days
    • Plex > View count equals 0 (or Tautulli > View count for multi-user servers)
  • Sonarr action: Unmonitor and delete files.

Here is the YAML for the unwatched TV show rule conditions:

mediaType: SHOWS
rules:
  - "0":
      - firstValue: Plex.addDate
        action: BEFORE
        customValue:
          type: custom_days
          value: "180"
      - operator: AND
        firstValue: Plex.viewCount
        action: EQUALS
        customValue:
          type: number
          value: 0
Code language: YAML (yaml)

Finished & Watched TV Shows

  • Name: TV Leaving – Finished
  • Library: TV Shows
  • Target: Shows
  • Take action after days: 14
  • Conditions (AND):
    • Sonarr > Ended equals true
    • Plex > View count is greater than 0 (if you share your server with other users, swap this for Tautulli > View count so shared plays count too)
    • Tautulli > Last view date is older than 90 days (or Plex > Last view date if you do not run Tautulli)
  • Sonarr action: Unmonitor and delete files.

Here is the YAML for the TV show rule conditions:

mediaType: SHOWS
rules:
  - "0":
      - firstValue: Sonarr.ended
        action: EQUALS
        customValue:
          type: boolean
          value: "true"
      - operator: AND
        firstValue: Plex.viewCount
        action: BIGGER
        customValue:
          type: number
          value: 0
      - operator: AND
        firstValue: Tautulli.lastViewedAt
        action: BEFORE
        customValue:
          type: custom_days
          value: "90"
Code language: YAML (yaml)

A quick head’s up if you use Radarr or Sonarr import lists: Maintainerr exclusions can block deleted items from re-adding later if your lists are still active. Double-check how your exclusions are configured if you plan to rotate seasonal movies in and out each year.

Spinning up Maintainerr gives you a predictable way to reclaim NAS space without playing bad cop with your Plex users. Pinning a “Leaving Soon” shelf on the home screen gives everyone a fair warning before anything actually disappears from disk.

Published on

by

Nick

Leave a Comment