mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 01:10:12 -08:00
docs: Add missing line breaks for improved readability in documentation files
This commit is contained in:
@@ -5,6 +5,7 @@ This document provides an overview of the `backup-media.sh` script, which is use
|
||||
## Script Overview
|
||||
|
||||
The script performs the following tasks:
|
||||
|
||||
1. Creates a log directory if it doesn't exist.
|
||||
2. Generates a log file with the current date and time.
|
||||
3. Defines a function to log file details.
|
||||
|
||||
@@ -7,6 +7,7 @@ The enhanced `backup-media.sh` script provides robust, enterprise-grade backup f
|
||||
## Features
|
||||
|
||||
### Core Functionality
|
||||
|
||||
- **Multi-service support**: Backs up 7 different media services
|
||||
- **Parallel execution**: Run multiple backups simultaneously for faster completion
|
||||
- **Verification**: Optional integrity checking of backed up files
|
||||
@@ -14,18 +15,21 @@ The enhanced `backup-media.sh` script provides robust, enterprise-grade backup f
|
||||
- **Performance monitoring**: Track backup duration and performance metrics
|
||||
|
||||
### Enhanced Logging
|
||||
|
||||
- **Multiple log formats**: Plain text, JSON, and Markdown reports
|
||||
- **Detailed tracking**: File sizes, checksums, timestamps, and status
|
||||
- **Performance logs**: JSON-formatted performance data for analysis
|
||||
- **Color-coded output**: Easy-to-read terminal output with status colors
|
||||
|
||||
### Safety Features
|
||||
|
||||
- **Dry run mode**: Preview operations without making changes
|
||||
- **Pre-flight checks**: Verify disk space and Docker availability
|
||||
- **Container verification**: Check if containers are running before backup
|
||||
- **Graceful error handling**: Continue with other services if one fails
|
||||
|
||||
### Maintenance
|
||||
|
||||
- **Automatic cleanup**: Remove old backups based on age and count limits
|
||||
- **Configurable retention**: Customize how many backups to keep
|
||||
- **Space management**: Monitor and report disk usage
|
||||
@@ -33,6 +37,7 @@ The enhanced `backup-media.sh` script provides robust, enterprise-grade backup f
|
||||
## Usage
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# Run standard backup
|
||||
./backup-media.sh
|
||||
@@ -64,6 +69,7 @@ The enhanced `backup-media.sh` script provides robust, enterprise-grade backup f
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
The script uses several configurable parameters at the top of the file:
|
||||
|
||||
```bash
|
||||
@@ -82,6 +88,7 @@ PERFORMANCE_MONITORING=true # Track performance metrics
|
||||
```
|
||||
|
||||
### Services Configuration
|
||||
|
||||
The script automatically detects and backs up these services:
|
||||
|
||||
| Service | Container Path | Backup Content |
|
||||
@@ -97,12 +104,14 @@ The script automatically detects and backs up these services:
|
||||
## Output Files
|
||||
|
||||
### Log Files
|
||||
|
||||
- **Text Log**: `media-backup-YYYYMMDD_HHMMSS.log` - Standard log format
|
||||
- **Markdown Report**: `media-backup-YYYYMMDD_HHMMSS.md` - Human-readable report
|
||||
- **JSON Log**: `media-backup.json` - Machine-readable backup status
|
||||
- **Performance Log**: `media-backup-performance.json` - Performance metrics
|
||||
|
||||
### Backup Structure
|
||||
|
||||
```
|
||||
/mnt/share/media/backups/
|
||||
├── logs/
|
||||
@@ -142,6 +151,7 @@ WEBHOOK_URL="https://notify.peterwood.rocks/lab"
|
||||
```
|
||||
|
||||
Notification includes:
|
||||
|
||||
- Backup status (success/failure)
|
||||
- Number of successful/failed services
|
||||
- Total execution time
|
||||
@@ -150,12 +160,14 @@ Notification includes:
|
||||
## Performance Monitoring
|
||||
|
||||
When enabled, the script tracks:
|
||||
|
||||
- Individual service backup duration
|
||||
- Overall script execution time
|
||||
- Timestamps for performance analysis
|
||||
- JSON format for easy parsing and graphing
|
||||
|
||||
Example performance log entry:
|
||||
|
||||
```json
|
||||
{
|
||||
"timestamp": "2025-05-25T14:30:22-05:00",
|
||||
@@ -178,7 +190,9 @@ The script provides robust error handling:
|
||||
## Integration
|
||||
|
||||
### Cron Job
|
||||
|
||||
Add to crontab for automated daily backups:
|
||||
|
||||
```bash
|
||||
# Daily at 2 AM
|
||||
0 2 * * * /home/acedanger/shell/backup-media.sh >/dev/null 2>&1
|
||||
@@ -188,7 +202,9 @@ Add to crontab for automated daily backups:
|
||||
```
|
||||
|
||||
### Monitoring
|
||||
|
||||
Use the JSON logs for monitoring integration:
|
||||
|
||||
```bash
|
||||
# Check last backup status
|
||||
jq '.sonarr.status' /home/acedanger/shell/logs/media-backup.json
|
||||
@@ -202,30 +218,38 @@ jq '.[] | select(.operation == "full_media_backup")' /home/acedanger/shell/logs/
|
||||
### Common Issues
|
||||
|
||||
1. **Container Not Running**
|
||||
|
||||
```
|
||||
WARNING: Container 'sonarr' is not running
|
||||
```
|
||||
|
||||
- Verify the container is running: `docker ps`
|
||||
- Start the container: `docker start sonarr`
|
||||
|
||||
2. **Permission Denied**
|
||||
|
||||
```
|
||||
ERROR: Backup failed for sonarr
|
||||
```
|
||||
|
||||
- Check Docker permissions
|
||||
- Verify backup directory permissions
|
||||
- Ensure script has execute permissions
|
||||
|
||||
3. **Disk Space**
|
||||
|
||||
```
|
||||
ERROR: Insufficient disk space
|
||||
```
|
||||
|
||||
- Free up space in backup directory
|
||||
- Adjust `MAX_BACKUP_AGE_DAYS` for more aggressive cleanup
|
||||
- Run manual cleanup: `find /mnt/share/media/backups -mtime +7 -delete`
|
||||
|
||||
### Debug Mode
|
||||
|
||||
For troubleshooting, run with verbose output:
|
||||
|
||||
```bash
|
||||
# Enable debugging
|
||||
bash -x ./backup-media.sh --dry-run
|
||||
@@ -259,6 +283,7 @@ docker exec sonarr ls -la /config/Backups/scheduled
|
||||
## Future Enhancements
|
||||
|
||||
Potential improvements for future versions:
|
||||
|
||||
- Database integrity checking for specific services
|
||||
- Compression of backup archives
|
||||
- Remote backup destinations (S3, rsync, etc.)
|
||||
|
||||
@@ -5,6 +5,7 @@ This document provides an overview and step-by-step explanation of the `folder-m
|
||||
## Script Overview
|
||||
|
||||
The script performs the following main tasks:
|
||||
|
||||
1. Checks if a directory is provided as an argument.
|
||||
2. Calculates the disk usage of the directory.
|
||||
3. Iterates over each subdirectory to calculate disk usage and file count.
|
||||
@@ -64,9 +65,11 @@ To use the script, run it with the directory path as an argument:
|
||||
## Important Information
|
||||
|
||||
- Ensure that the script is executable. You can make it executable with the following command:
|
||||
|
||||
```shell
|
||||
chmod +x folder-metrics.sh
|
||||
```
|
||||
|
||||
- The script requires a directory path as an argument. Ensure that you provide a valid directory path when running the script.
|
||||
|
||||
By following this documentation, you should be able to understand and use the `folder-metrics.sh` script effectively.
|
||||
|
||||
@@ -5,6 +5,7 @@ This document provides an overview and step-by-step explanation of the `plex.sh`
|
||||
## Script Overview
|
||||
|
||||
The script performs the following main tasks:
|
||||
|
||||
1. Starts the Plex Media Server.
|
||||
2. Stops the Plex Media Server.
|
||||
3. Restarts the Plex Media Server.
|
||||
@@ -71,9 +72,11 @@ To use the script, run it with one of the following parameters:
|
||||
## Important Information
|
||||
|
||||
- Ensure that the script is executable. You can make it executable with the following command:
|
||||
|
||||
```shell
|
||||
chmod +x plex.sh
|
||||
```
|
||||
|
||||
- The script uses `systemctl` to manage the Plex Media Server service. Ensure that `systemctl` is available on your system.
|
||||
- The script requires `sudo` privileges to manage the Plex Media Server service. Ensure that you have the necessary permissions to run the script with `sudo`.
|
||||
|
||||
|
||||
@@ -62,12 +62,14 @@ sudo ./backup-plex.sh --check-integrity --non-interactive
|
||||
### 4. Test Notification Systems
|
||||
|
||||
#### Webhook Testing
|
||||
|
||||
```bash
|
||||
# Replace with your actual webhook URL
|
||||
sudo ./backup-plex.sh --check-integrity --webhook=https://your-webhook-endpoint.com/test
|
||||
```
|
||||
|
||||
#### Email Testing
|
||||
|
||||
```bash
|
||||
# Replace with your email address
|
||||
sudo ./backup-plex.sh --check-integrity --email=admin@yourdomain.com
|
||||
@@ -83,6 +85,7 @@ sudo ./backup-plex.sh --non-interactive
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
|
||||
- [ ] Plex service stopped and restarted properly
|
||||
- [ ] Backup files created in `/mnt/share/media/backups/plex/YYYYMMDD/`
|
||||
- [ ] Log files updated in `/mnt/share/media/backups/logs/`
|
||||
@@ -194,6 +197,7 @@ Schedule weekly backup validation:
|
||||
### Common Issues
|
||||
|
||||
#### 1. Permission Denied Errors
|
||||
|
||||
```bash
|
||||
# Fix script permissions
|
||||
chmod +x /home/acedanger/shell/*.sh
|
||||
@@ -203,6 +207,7 @@ sudo chown -R $(whoami):$(whoami) /mnt/share/media/backups/
|
||||
```
|
||||
|
||||
#### 2. Plex Service Issues
|
||||
|
||||
```bash
|
||||
# Check Plex service status
|
||||
sudo systemctl status plexmediaserver
|
||||
@@ -212,6 +217,7 @@ sudo systemctl restart plexmediaserver
|
||||
```
|
||||
|
||||
#### 3. Insufficient Disk Space
|
||||
|
||||
```bash
|
||||
# Check available space
|
||||
df -h /mnt/share/media/backups/
|
||||
@@ -221,6 +227,7 @@ df -h /mnt/share/media/backups/
|
||||
```
|
||||
|
||||
#### 4. Database Integrity Issues
|
||||
|
||||
```bash
|
||||
# Run integrity check only
|
||||
sudo ./backup-plex.sh --check-integrity --auto-repair
|
||||
@@ -232,20 +239,24 @@ sudo ./backup-plex.sh --auto-repair
|
||||
### Performance Optimization
|
||||
|
||||
#### 1. Parallel Processing
|
||||
|
||||
- Enable parallel verification for faster backups (default: enabled)
|
||||
- Disable with `--no-parallel` if experiencing issues
|
||||
|
||||
#### 2. Performance Monitoring
|
||||
|
||||
- Disable with `--no-performance` if not needed
|
||||
- Monitor trends to optimize backup timing
|
||||
|
||||
#### 3. Notification Optimization
|
||||
|
||||
- Use webhooks instead of email for faster notifications
|
||||
- Configure webhook endpoints with proper error handling
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### 1. File Permissions
|
||||
|
||||
```bash
|
||||
# Secure backup files
|
||||
chmod 600 /home/acedanger/shell/logs/plex-backup*.json
|
||||
@@ -253,11 +264,13 @@ chmod 700 /mnt/share/media/backups/plex/
|
||||
```
|
||||
|
||||
### 2. Webhook Security
|
||||
|
||||
- Use HTTPS endpoints for webhooks
|
||||
- Implement webhook signature verification if possible
|
||||
- Avoid including sensitive data in webhook payloads
|
||||
|
||||
### 3. Access Control
|
||||
|
||||
- Limit script execution to authorized users
|
||||
- Consider using dedicated backup user account
|
||||
- Regularly audit file access permissions
|
||||
@@ -273,6 +286,7 @@ The script automatically manages backup retention:
|
||||
## Recovery Planning
|
||||
|
||||
### 1. Backup Restoration
|
||||
|
||||
```bash
|
||||
# List available backups
|
||||
./restore-plex.sh --list
|
||||
@@ -282,6 +296,7 @@ sudo ./restore-plex.sh --restore YYYYMMDD
|
||||
```
|
||||
|
||||
### 2. Emergency Procedures
|
||||
|
||||
1. Stop Plex service: `sudo systemctl stop plexmediaserver`
|
||||
2. Backup current data: `./restore-plex.sh --backup-current`
|
||||
3. Restore from backup: `sudo ./restore-plex.sh --restore YYYYMMDD`
|
||||
@@ -301,12 +316,14 @@ Monitor these metrics to ensure backup system health:
|
||||
## Support and Updates
|
||||
|
||||
### Getting Help
|
||||
|
||||
1. Check logs for error messages
|
||||
2. Run validation tools for diagnosis
|
||||
3. Review troubleshooting guide
|
||||
4. Test with `--check-integrity` for safe debugging
|
||||
|
||||
### Script Updates
|
||||
|
||||
- Keep scripts updated with latest features
|
||||
- Test updates in non-production environment first
|
||||
- Backup current scripts before updating
|
||||
|
||||
@@ -9,6 +9,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
### 1. Enhanced Backup Script (`backup-plex.sh`)
|
||||
|
||||
**Core Functionality:**
|
||||
|
||||
- ✅ Intelligent backup detection (only backs up changed files)
|
||||
- ✅ WAL file handling with automatic checkpointing
|
||||
- ✅ Database integrity verification with automated repair options
|
||||
@@ -17,6 +18,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
- ✅ Safe Plex service management
|
||||
|
||||
**Advanced Features:**
|
||||
|
||||
- ✅ JSON-based performance monitoring
|
||||
- ✅ Multi-channel notification system (console, webhook, email)
|
||||
- ✅ Checksum caching for efficiency
|
||||
@@ -25,6 +27,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
- ✅ Non-interactive mode for automation
|
||||
|
||||
**Command Line Options:**
|
||||
|
||||
```bash
|
||||
./backup-plex.sh [OPTIONS]
|
||||
--auto-repair Automatically attempt to repair corrupted databases
|
||||
@@ -40,6 +43,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
### 2. Comprehensive Testing Framework
|
||||
|
||||
**Unit Testing (`test-plex-backup.sh`):**
|
||||
|
||||
- ✅ 9 comprehensive unit tests covering all major functionality
|
||||
- ✅ JSON log initialization testing
|
||||
- ✅ Performance tracking validation
|
||||
@@ -53,6 +57,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
- ✅ **Current Status: 100% test pass rate**
|
||||
|
||||
**Integration Testing (`integration-test-plex.sh`):**
|
||||
|
||||
- ✅ 8 comprehensive integration tests
|
||||
- ✅ Command line argument parsing
|
||||
- ✅ Performance monitoring features
|
||||
@@ -67,6 +72,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
### 3. Monitoring and Validation Tools
|
||||
|
||||
**Monitoring Dashboard (`monitor-plex-backup.sh`):**
|
||||
|
||||
- ✅ Real-time system status monitoring
|
||||
- ✅ Backup status and health checks
|
||||
- ✅ Performance metrics display
|
||||
@@ -76,6 +82,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
- ✅ Watch mode for continuous monitoring
|
||||
|
||||
**Backup Validation (`validate-plex-backups.sh`):**
|
||||
|
||||
- ✅ Comprehensive backup integrity verification
|
||||
- ✅ Backup freshness monitoring
|
||||
- ✅ JSON log validation
|
||||
@@ -84,6 +91,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
- ✅ Detailed reporting capabilities
|
||||
|
||||
**Restore Functionality (`restore-plex.sh`):**
|
||||
|
||||
- ✅ Safe backup restoration
|
||||
- ✅ Backup listing and validation
|
||||
- ✅ Current data backup before restore
|
||||
@@ -92,6 +100,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
### 4. Documentation Suite
|
||||
|
||||
**Enhanced Documentation (`docs/enhanced-plex-backup.md`):**
|
||||
|
||||
- ✅ Comprehensive feature documentation
|
||||
- ✅ Usage examples and best practices
|
||||
- ✅ Performance monitoring guide
|
||||
@@ -100,6 +109,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
- ✅ Troubleshooting guide
|
||||
|
||||
**Production Deployment Guide (`docs/production-deployment-guide.md`):**
|
||||
|
||||
- ✅ Pre-deployment checklist
|
||||
- ✅ System requirements verification
|
||||
- ✅ Step-by-step deployment instructions
|
||||
@@ -110,23 +120,27 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
- ✅ Performance optimization tips
|
||||
|
||||
**Original Documentation (`docs/plex-backup.md`):**
|
||||
|
||||
- ✅ Preserved original documentation for reference
|
||||
- ✅ Basic usage instructions maintained
|
||||
|
||||
## 📊 Current System Status
|
||||
|
||||
### Test Results
|
||||
|
||||
- **Unit Tests**: 9/9 passing (100% success rate)
|
||||
- **Integration Tests**: 8/8 passing (100% success rate)
|
||||
- **System Validation**: All core components verified
|
||||
|
||||
### Performance Metrics
|
||||
|
||||
- **Script Execution**: Optimized with parallel processing
|
||||
- **Backup Detection**: Intelligent change detection reduces unnecessary work
|
||||
- **Service Downtime**: Minimized through efficient database operations
|
||||
- **Storage Usage**: Automatic cleanup and compression
|
||||
|
||||
### Monitoring Capabilities
|
||||
|
||||
- **Real-time Dashboard**: Comprehensive system health monitoring
|
||||
- **Automated Validation**: Regular backup integrity checks
|
||||
- **Performance Tracking**: JSON-based operation timing
|
||||
@@ -139,6 +153,7 @@ This document summarizes the completed enhanced Plex Media Server backup system
|
||||
The enhanced Plex backup system is fully tested, documented, and ready for production deployment. All major features have been implemented, tested, and validated.
|
||||
|
||||
### Deployment Checklist
|
||||
|
||||
- ✅ **Core Functionality**: All features implemented and tested
|
||||
- ✅ **Error Handling**: Comprehensive error recovery mechanisms
|
||||
- ✅ **Testing Framework**: 100% test coverage with passing tests
|
||||
@@ -150,6 +165,7 @@ The enhanced Plex backup system is fully tested, documented, and ready for produ
|
||||
## 📋 Recommended Next Steps
|
||||
|
||||
### 1. Production Deployment
|
||||
|
||||
```bash
|
||||
# Follow the production deployment guide
|
||||
cd /home/acedanger/shell
|
||||
@@ -159,6 +175,7 @@ sudo ./backup-plex.sh --non-interactive # First production backup
|
||||
```
|
||||
|
||||
### 2. Automated Scheduling
|
||||
|
||||
```bash
|
||||
# Set up daily automated backups
|
||||
sudo crontab -e
|
||||
@@ -166,6 +183,7 @@ sudo crontab -e
|
||||
```
|
||||
|
||||
### 3. Monitoring Setup
|
||||
|
||||
```bash
|
||||
# Monitor backup system health
|
||||
./monitor-plex-backup.sh --watch # Continuous monitoring
|
||||
@@ -173,11 +191,13 @@ sudo crontab -e
|
||||
```
|
||||
|
||||
### 4. Notification Configuration
|
||||
|
||||
- Configure webhook endpoints for real-time alerts
|
||||
- Set up email notifications for backup status
|
||||
- Test notification delivery with actual endpoints
|
||||
|
||||
### 5. Performance Optimization
|
||||
|
||||
- Monitor performance logs for optimization opportunities
|
||||
- Adjust parallel processing settings based on system performance
|
||||
- Fine-tune retention policies based on storage requirements
|
||||
|
||||
@@ -37,7 +37,7 @@ Improved package detection, especially for packages like `cowsay` and `lolcat` t
|
||||
|
||||
- Enhanced `test_package()` function to check in common alternate locations
|
||||
- Added specific handling for packages that may be installed with different paths
|
||||
- Added detailed debugging output for problematic packages
|
||||
- Added detailed debugging output for problematic packages
|
||||
|
||||
### 4. Docker Container Configuration
|
||||
|
||||
|
||||
@@ -23,10 +23,12 @@ The testing framework consists of three main components:
|
||||
### The Docker Test Environment
|
||||
|
||||
The `Dockerfile` defines two testing environments:
|
||||
|
||||
- **ubuntu-test**: Based on Ubuntu 24.04
|
||||
- **debian-test**: Based on Debian 12
|
||||
|
||||
Each environment:
|
||||
|
||||
1. Installs minimal dependencies (curl, git, sudo, wget)
|
||||
2. Creates a test user with sudo permissions
|
||||
3. Sets up the directory structure for testing
|
||||
@@ -100,12 +102,14 @@ The testing framework offers different options for different testing needs:
|
||||
### Key Differences
|
||||
|
||||
**Standard Tests** (`ubuntu`, `debian`):
|
||||
|
||||
- Use the Docker targets defined in the main Dockerfile
|
||||
- Run the `test-setup.sh` script to check components
|
||||
- Faster execution, focused on component validation
|
||||
- Don't perform the actual bootstrap installation
|
||||
|
||||
**Full Tests** (`full-ubuntu`, `full-debian`):
|
||||
|
||||
- Create a temporary Dockerfile for comprehensive testing
|
||||
- Execute the bootstrap script directly from GitHub
|
||||
- Complete end-to-end testing of the actual installation process
|
||||
@@ -123,10 +127,12 @@ The test provides:
|
||||
## Adding New Tests
|
||||
|
||||
To add new package tests:
|
||||
|
||||
1. Add the package name to `setup/packages.list`
|
||||
2. The test framework will automatically validate its availability and installation
|
||||
|
||||
For more complex components:
|
||||
|
||||
1. Add a new test function in `test-setup.sh`
|
||||
2. Call the function in the main testing sequence
|
||||
3. Increment the error counter if the test fails
|
||||
|
||||
Reference in New Issue
Block a user