Your Plex database contains years of watch history, custom collections, user preferences, metadata edits, and library configurations. If your server drive fails, a bad update corrupts the database, or you’re migrating to new hardware, a good backup strategy is the difference between a 10-minute restore and rebuilding everything from scratch.
What Actually Needs Backing Up
Not everything in your Plex data directory is equally important:
- Critical: Plex database (
com.plexapp.plugins.library.db) — Contains all metadata, watch history, user data, collections, playlists, and library configuration. This is the single most important file - Critical: Preferences.xml — Server settings, claim token, network configuration, custom scanner settings
- Important: Metadata directory — Cached posters, art, and thumbnails. Can be re-downloaded but takes hours for large libraries
- Optional: Cache — Transcoder cache, analysis thumbnails. Fully regenerable. Typically 5–50 GB and not worth backing up
- Not needed: Codecs — Downloaded automatically on first use
Backup Methods
1. Scheduled Database Backup (Recommended)
Plex has a built-in scheduled backup under Settings → Scheduled Tasks. It creates compressed backups of the database on a configurable schedule. The default keeps 3 backups in the Plug-in Support/Databases directory.
The problem: these backups are stored on the same drive as the database. If the drive fails, you lose both. Always copy them offsite.
2. Manual SQLite Backup
For a clean backup while Plex is running, use SQLite’s built-in backup command:
sqlite3 "com.plexapp.plugins.library.db" ".backup '/path/to/backup/plex-$(date +%Y%m%d).db'"
This creates a consistent snapshot without stopping the server. Never just copy the .db file while Plex is running — you’ll get a corrupted backup if a write is in progress.
3. Full Data Directory Snapshot
For complete disaster recovery, back up the entire Plex data directory:
- Linux:
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/ - Docker: Your mapped config volume
- Windows:
%LOCALAPPDATA%\Plex Media Server\ - macOS:
~/Library/Application Support/Plex Media Server/
Stop Plex first for a clean snapshot, or use filesystem-level snapshots (ZFS, Btrfs, LVM) for zero-downtime backups.
Automated Offsite Backup Script
A minimal cron-based approach that covers most setups:
#!/bin/bash # Daily Plex backup to remote storage PLEX_DB="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases" BACKUP_DIR="/mnt/backup/plex" DATE=$(date +%Y%m%d) # SQLite safe backup sqlite3 "$PLEX_DB/com.plexapp.plugins.library.db" ".backup '$BACKUP_DIR/plex-$DATE.db'" # Copy preferences cp "$PLEX_DB/../../Preferences.xml" "$BACKUP_DIR/Preferences-$DATE.xml" # Sync to remote (rclone, rsync, or S3) rclone sync "$BACKUP_DIR" remote:plex-backups --max-age 30d # Keep 14 days locally find "$BACKUP_DIR" -name "plex-*.db" -mtime +14 -delete
Docker-Specific Backup
If you run Plex in Docker, your config volume is the backup target. The cleanest approach:
docker stop plex tar czf /backup/plex-config-$(date +%Y%m%d).tar.gz /path/to/plex/config docker start plex
Downtime is typically under 60 seconds. For zero-downtime, use the SQLite backup method above instead of stopping the container.
Testing Your Backups
A backup you haven’t tested is not a backup. Verify regularly:
- Run
sqlite3 backup.db "PRAGMA integrity_check;"— should returnok - Check file sizes are reasonable (a healthy database for 5,000+ items is typically 100 MB–2 GB)
- Test a full restore on a spare machine or Docker container at least once
- Verify your offsite copies are actually accessible and current