feat: Add cleanup script for temporary and corrupted Plex database files

This commit is contained in:
Peter Wood
2025-06-21 07:52:16 -04:00
parent 9b83924597
commit cf4b54cf0a
2 changed files with 340 additions and 0 deletions

View File

@@ -307,6 +307,36 @@ $ ./check-plex-builtin-backups.sh
./plex-recent-additions.sh # Generate recent additions report
```
#### `cleanup-plex-databases.sh` ⭐ **NEW**
**Safe cleanup of temporary and corrupted database files**
**Features:**
- Removes temporary files, recovery files, and corrupted directories
- Preserves active databases and legitimate backups
- Dry-run mode for safe preview
- Comprehensive safety checks and validation
**Usage:**
```bash
./cleanup-plex-databases.sh --dry-run # Preview what will be removed
sudo ./cleanup-plex-databases.sh # Perform actual cleanup
./cleanup-plex-databases.sh --help # Show all options
```
**What it removes:**
- Temporary files (`*-tmp`, `*-2025-*-tmp`)
- MD5 checksum files (`*.md5`)
- Recovery files (`*recovery*`)
- Repaired files (`*repaired*`)
- Empty backup files (`*empty-backup*`)
- Repair log files (`DBRepair.log`)
- Corrupted database directories (`corrupted-*`)
**What it preserves:**
- Active database files (`*.db`, `*.db-shm`, `*.db-wal`)
- Plex built-in backups (`*.backup.*`)
- Historical dated backups (`*.db.YYYYMMDD`)
- EPG databases (`tv.plex.providers.epg.cloud-*.db`)
### 🧪 Testing & Integration
#### `test-plex-backup.sh`