This repository contains all automation scripts, optimizations, and configurations for a high-performance Pi-hole DNS server running on Raspberry Pi Zero 2 W.
βββ scripts/
β βββ automation/ # Automated maintenance scripts
β βββ optimization/ # Performance optimization scripts
β βββ management/ # Management and utility scripts
βββ configs/
β βββ pihole/ # Pi-hole specific configurations
β βββ system/ # Systemd services and timers
β βββ unbound/ # Unbound DNS resolver configs
βββ docs/ # Documentation and guides
βββ backups/ # Configuration backups
βββ deploy/ # Deployment scripts
- Pi-hole Gravity Updates: Weekly automated blocklist updates with health checks
- System Updates: Automated OS security and package updates
- Performance Monitoring: System resource monitoring and alerting
- Pi-hole Performance: DNS cache optimization for limited RAM (416MB)
- System Performance: Kernel parameter tuning for DNS workloads
- Unbound Optimization: DNS resolver tuning for Pi Zero 2 W hardware
- Backup & Restore: Complete configuration backup and rollback procedures
- Health Monitoring: Service status checking and performance validation
- Update Management: Selective update controls (security-only vs full updates)
- Raspberry Pi Zero 2 W (or similar low-resource Pi)
- Raspberry Pi OS (Debian-based)
- Pi-hole installed and configured
- Unbound DNS resolver (optional but recommended)
-
Clone this repository:
git clone <repository-url> cd pi-scripts-backup
-
Run the deployment script:
sudo ./deploy/install.sh
-
Verify services are running:
./scripts/management/system-health-check.sh
- Pi-hole Gravity: Weekly updates on Sundays at 3:00 AM
- System Updates: Weekly updates on Saturdays at 2:00 AM
- Randomization: Up to 30-60 minutes delay to distribute load
- DNS Cache: Optimized for 416MB RAM system
- Memory Management: Reduced swap usage and memory pressure
- Network Tuning: UDP buffer optimizations for DNS workloads
- DNS Query Time: 4ms average
- Available RAM: 268MB
- Swap Usage: 69MB
- System Load: 0.29
- DNS Query Time: 0ms (cached), 4ms (uncached)
- Available RAM: 299MB (+30MB improvement)
- Swap Usage: 43MB (-26MB improvement)
- System Load: 0.17 (-41% improvement)
All configurations are automatically backed up before any changes:
- Pi-hole configs:
/home/pi/pihole-backups/ - System configs:
/home/pi/system-backups/ - Unbound configs:
/home/pi/unbound-backups/
Complete rollback available via:
sudo /home/pi/scripts/rollback-optimizations.sh# Check Pi-hole status and next update
./scripts/management/pihole-gravity-manager.sh status
# Manual gravity update
./scripts/management/pihole-gravity-manager.sh run
# View update logs
./scripts/management/pihole-gravity-manager.sh logs# Check system status and available updates
./scripts/management/raspi-update-manager.sh summary
# Run security updates only
./scripts/management/raspi-update-manager.sh security
# Full system update
./scripts/management/raspi-update-manager.sh run- Pi-hole Updates:
/var/log/pihole-scripts/ - System Updates:
/var/log/system-update/ - Service Logs:
journalctl -u <service-name>
- DNS resolution testing
- Service availability monitoring
- Resource usage validation
- Network connectivity verification
- Model: Raspberry Pi Zero 2 W
- RAM: 512MB (416MB available to OS)
- CPU: Quad-core ARM Cortex-A53 @ 1GHz
- Storage: MicroSD (minimum 16GB recommended)
- RAM Usage: ~117MB for system + Pi-hole + Unbound
- CPU Usage: ~5% average with DNS queries
- Disk Usage: ~2.6GB for OS + applications + logs
Feel free to submit issues, feature requests, or improvements via GitHub issues and pull requests.
This project is open source and available under the MIT License.
These scripts are optimized for Raspberry Pi Zero 2 W hardware constraints. Adjust configurations as needed for different hardware specifications.
Last Updated: July 2025
Compatible with: Raspberry Pi OS (Debian 12 "Bookworm"), Pi-hole v5.x+, Unbound 1.17+