/api/maintenance, and the SQLite database can be compacted directly from the command line when disk reclamation is needed.
Maintenance API Endpoints
The maintenance controller exposes three endpoints. All are available immediately after startup with no authentication required by default (apply reverse-proxy authentication if your instance is publicly accessible).Garbage Collection
Calling the GC endpoint is a low-risk operation that can be done at any time without stopping ErsatzTV. It is rarely necessary — the .NET runtime manages memory automatically — but can be useful after a large library import or playout rebuild if you notice memory usage is elevated and has not returned to baseline.Emptying the Trash
When ErsatzTV detects that media files have been removed from disk or a library source has been disconnected, those items are not immediately deleted from the database — they are moved to a soft-deleted “trash” state. This preserves playout history and schedule references while giving you a chance to review what was removed. Emptying the trash permanently removes all trashed items from the database. This action is irreversible, so confirm the trashed items are genuinely gone before proceeding.Cleaning the Artwork Cache
The artwork cache stores poster images, thumbnails, fan art, logos, and watermarks downloaded from your media server integrations. Over time, artwork associated with deleted media items can become orphaned — the file exists in the cache folder but no database record references it. Theclean_artwork endpoint queues a background job (processed by the worker service) that:
- Identifies actors with no remaining metadata references and deletes them.
- Identifies artwork records with no remaining media references and deletes them and their cache files.
- Removes empty subdirectories from the artwork cache folder.
SQLite Database Maintenance
ErsatzTV Legacy stores all configuration, schedule data, playout history, media metadata, and channel settings in a SQLite database atersatztv.sqlite3 in the config folder (i.e. /config/ersatztv.sqlite3 in Docker). SQLite uses a Write-Ahead Log (WAL) alongside the main database file — after large deletions (such as removing an Emby or Jellyfin library, or emptying the trash), the WAL can hold a significant amount of data that has not yet been checkpointed back into the main file.
Running a WAL checkpoint followed by a VACUUM compacts the database and reclaims the disk space freed by deletions.
When to Run VACUUM
Run the SQLite VACUUM procedure after any of the following events:- Removing a large Emby or Jellyfin library from ErsatzTV.
- Emptying the trash after a bulk media deletion.
- Cleaning orphaned artwork (after seeing
No orphaned actors to deleteandNo orphaned artwork to deletein the logs). - Noticing that the database file (
ersatztv.sqlite3) is unexpectedly large relative to your current library size.
Reclaiming Disk Space with SQLite
1
Confirm artwork cleanup is complete
Before vacuuming, trigger the artwork cleanup API and wait for the background job to complete. Monitor Settings → Logs until you see both
No orphaned actors to delete and No orphaned artwork to delete. This ensures that all orphaned records are removed from the database before compaction.2
Stop ErsatzTV Legacy
Stop the container before touching the database file.
3
Navigate to the config directory
Access the config volume on the host. If you used the default named volume from the Compose file, find its mount point with:Then change to that directory (the
Mountpoint value), or use docker run --rm -v ersatztv:/data -w /data to run commands against the volume directly.4
Run WAL checkpoint and VACUUM
Execute the following two SQLite pragmas in a single command. The A
PRAGMA wal_checkpoint(TRUNCATE) flushes and truncates the WAL file; VACUUM rewrites the main database file to reclaim freed space.VACUUM on a large database (several gigabytes) may take several minutes. The command will return to the prompt when complete.5
Restart ErsatzTV Legacy
Once VACUUM completes, restart the container normally.ErsatzTV will reopen the database and resume normal operation.
MySQL Support
For users who prefer MySQL over SQLite (for example, when hosting ErsatzTV on a server that already runs MySQL and want centralised database management), ErsatzTV Legacy includes theErsatzTV.Infrastructure.MySql project. MySQL support allows the same ErsatzTV application to store all data in a MySQL or MariaDB instance instead of the local SQLite file.
MySQL configuration is not yet documented here — if you are using MySQL, refer to the
ErsatzTV.Infrastructure.MySql project in the source repository for the connection string format and any additional environment variables required.OPTIMIZE TABLE, mysqlcheck) for equivalent table compaction.
Backup Recommendations
The entire/config directory is the single source of truth for your ErsatzTV installation. Back it up regularly, especially before upgrades. It contains:
A minimal Docker backup using
docker run:
