Add advanced Plex database recovery and restoration scripts

- Introduced `recover-plex-database.sh` for comprehensive database recovery with multiple strategies, logging, and rollback capabilities.
- Added `restore-plex.sh` for safe restoration of Plex backups, including validation and dry-run options.
- Created `plex-db-manager.sh` to consolidate database management functionalities, including integrity checks and service management.
- Enhanced logging and error handling across all scripts for better user feedback and troubleshooting.
- Implemented safety measures to prevent running scripts as root and ensure proper service management during operations.
This commit is contained in:
Peter Wood
2025-06-21 07:23:33 -04:00
parent 30a252a500
commit 9b83924597
13 changed files with 1410 additions and 300 deletions

View File

@@ -11,16 +11,19 @@
# Backs up all Docker .env files to private Gitea repository
0 2 * * * { echo "Starting .env files backup"; /home/acedanger/shell/backup-env-files.sh; echo ".env backup completed with exit code: $?"; } 2>&1 | logger -t env-backup -p user.info
# Daily Plex database integrity check every 30 minutes
*/30 * * * * { echo "Check Plex database corruption"; /home/acedanger/shell/plex/backup-plex.sh --check-integrity --auto-repair; } 2>&1 | logger -t plex-database-integrity-check -p user.info
# DISABLED: Custom Plex backup system (June 21, 2025)
# Reason: Plex built-in scheduled backups are now handling database backups every 3 days
# Built-in backups location: /var/lib/plexmediaserver/.../Databases/*.backup.*
# Custom backups no longer needed - Plex's native system is more reliable
# Daily Plex backup at 0415 with enhanced logging
# Includes execution status and performance metrics
15 4 * * * { echo "Starting Plex backup"; /home/acedanger/shell/plex/backup-plex.sh --non-interactive --auto-repair; echo "Plex backup completed with exit code: $?"; } 2>&1 | logger -t plex-backup -p user.info
# Optional: Weekly database integrity check (read-only) - keeping for health monitoring
# 0 6 * * 0 { echo "Weekly Plex database integrity check (read-only)"; /home/acedanger/shell/plex/plex-db-manager.sh check; } 2>&1 | logger -t plex-health-check -p user.info
# Daily validation at 0700 with detailed logging
# Logs validation results and any auto-fixes performed
0 7 * * * { echo "Starting Plex backup validation"; /home/acedanger/shell/plex/validate-plex-backups.sh --fix; echo "Validation completed with exit code: $?"; } 2>&1 | logger -t plex-validation -p user.info
# DISABLED - Custom daily Plex backup (replaced by Plex built-in backups)
# 15 4 * * * { echo "Starting Plex backup"; /home/acedanger/shell/plex/backup-plex.sh --non-interactive --disable-auto-repair; echo "Plex backup completed with exit code: $?"; } 2>&1 | logger -t plex-backup -p user.info
# DISABLED - Custom backup validation (no longer needed with built-in backups)
# 0 7 * * * { echo "Starting Plex backup validation"; /home/acedanger/shell/plex/validate-plex-backups.sh --fix; echo "Validation completed with exit code: $?"; } 2>&1 | logger -t plex-validation -p user.info
# Backup Immich database weekly (Mondays at 0500)
# Enhanced with proper logging and error handling
@@ -29,9 +32,8 @@
# Daily system backup at 0400 with auto-cleanup
0 4 * * * /home/acedanger/shell/crontab/crontab-backup-system.sh backup auto --auto-cleanup 2>&1 | logger -t crontab-backup -p user.info
# Generate detailed weekly report (Sundays at 0800)
# Comprehensive reporting with system logging
0 8 * * 0 { echo "Starting weekly Plex backup report generation"; /home/acedanger/shell/plex/validate-plex-backups.sh --report; echo "Weekly report generation completed with exit code: $?"; } 2>&1 | logger -t plex-report -p user.info
# DISABLED - Weekly Plex backup report (no longer needed)
# 0 8 * * 0 { echo "Starting weekly Plex backup report generation"; /home/acedanger/shell/plex/validate-plex-backups.sh --report; echo "Weekly report generation completed with exit code: $?"; } 2>&1 | logger -t plex-report -p user.info
# Weekly .env backup validation (Sundays at 0830)
# Validates integrity of .env backup repository