This script automates the upgrade of various Wazuh components (Indexer, Manager, and Dashboard) with enhanced safety features including backup/restore capabilities and health checks.
pip install -r requirements.txt
Required Python packages:
- requests
- lxml
- python-dotenv
- typing-extensions
- Debian/Ubuntu-based system with
apt
package manager - Root/sudo access
- Required system tools:
- curl
- apt-get
- systemctl
- tar
Create a .env
file with:
WAZUH_USERNAME=<your_wazuh_username>
WAZUH_PASSWORD=<your_wazuh_password>
- Automatic component detection and ordered upgrades
- Backup and restore capabilities
- Health checks pre/post upgrade
- Automatic rollback on failure
- Exponential backoff retry mechanism
- Comprehensive logging
- Component state tracking
- Configuration backups
- Version tracking
- Automatic rollback on failure
- Health verification after upgrades
Basic execution:
sudo python upgrade_wazuh.py
The script will:
- Validate environment and dependencies
- Create backups of existing configurations
- Perform upgrades in the correct order (Indexer → Manager → Dashboard)
- Verify health after each upgrade
- Automatically rollback if issues are detected
Backups are stored in /var/backup/wazuh/<component>/<timestamp>/
and include:
- Configuration files
- Component state information
- Version information
Automatic rollback occurs if:
- Component health check fails
- Upgrade process encounters errors
- Service fails to start
- Missing Dependencies
sudo apt-get update
sudo apt-get install curl gnupg apt-transport-https
- Permission Issues
sudo chmod -R 755 /var/backup/wazuh
- Health Check Failures
- Check component logs:
/var/log/wazuh-*
- Verify service status:
systemctl status wazuh-*
The script includes:
- Exponential backoff retry mechanism
- Detailed error logging
- Automatic rollback capabilities
- Health verification
Logs include:
- Command execution details
- Backup operations
- Health check results
- Error messages with stack traces
- Rollback operations
Backups can be found in /var/backup/wazuh/
organized by component and timestamp.
python upgrade_wazuh.py --status
Please submit issues and pull requests on GitHub.
MIT License
Created by Chuck