Skip to content

backup: add Plex SQLite databases to dump-sqlite.sh

jedmund requested to merge jedmund/backup-plex-sqlite into main

Created by: jedmund

Summary

Follow-up to PR 2 (the DB hooks PR). Plex's two SQLite databases were left out of the explicit .backup dump list because their path is deep and full of spaces, but the existing array-of-quoted-strings shape handles that fine. No reason not to include them.

What gets added

Two entries to the SQLITE_FILES array in dump-sqlite.sh:

  • /opt/docker/media-consumption/config/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db (main library metadata, watch state, play history, scan queue)
  • /opt/docker/media-consumption/config/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.blobs.db (artwork and poster blob cache)

Plus a small nullglob shim around the rm -f cleanup step so a fresh DUMP_DIR with no prior output doesn't pass a literal *.db to rm (harmless with -f but cleaner).

Why this matters

Plex's library DB is one of the most actively-written SQLite databases in the homelab during off-hours: background metadata scrape, intro detection, thumbnail generation, library scan jobs. The PR-2-era file-level snapshot captures whatever WAL/SHM state happens to be on disk at 02:00, which usually recovers on restore but isn't guaranteed. sqlite3 .backup uses the SQLite backup API and is safe with concurrent writers.

Commits

  1. backup: include Plex library and blobs DBs in SQLite dumps

Test plan

  • make deploy-backup redeploys with the updated script
  • docker exec borgmatic /scripts/dump-sqlite.sh runs cleanly (no errors about missing files or unquoted spaces)
  • ls /var/backup/dumps/sqlite/ | grep plex shows both Plex DBs flattened to filenames
  • Pick one of the dumped Plex DBs, run sqlite3 <dump> "PRAGMA integrity_check" and confirm it returns ok
  • Next nightly run completes with Plex DBs in the new archive

Merge request reports

Loading