Backup & Monitoring Utility Script
Overview
A utility script for Vodia PBX that provides automated service monitoring, self-healing capabilities, scheduled backups, and easy restoration from backups
Requirements
- Linux system with Vodia PBX installed at /usr/local/pbx
- Root access, Bash shell
Installation with recommended options
To install the backup and monitoring features:
wget https://vodia.nyc3.cdn.digitaloceanspaces.com/builds/pbx-monitor-backup.sh
chmod a+x pbx-monitor-backup.sh
./pbx-monitor-backup.sh --monitor-sip 5060 --backup
Monitoring Features
The installer includes a robust monitoring system that can check HTTP, HTTPS, and SIP ports. If any of these services become unresponsive, it will automatically restart the PBX.
Monitoring Options
./pbx-monitor-backup.sh --monitor-http 80 --monitor-https 443 --monitor-sip 5060
You can use any combination of these monitoring options:
--monitor-http PORT
: Monitors the HTTP service on the specified port
--monitor-https PORT
: Monitors the HTTPS service on the specified port
--monitor-sip PORT
: Monitors the SIP service on the specified port
--tolerance SECONDS
: Sets how long a service can be down before restarting (default: 300 seconds). Valid values: 60, 120, 180, 300, 600 seconds
--cooldown SECONDS
: Sets how long to wait after a restart before resuming monitoring (default: 300 seconds). Valid values: 120, 300, 600, 900, 1800 seconds
--warmup SECONDS
: After initial installation, monitoring won't restart services until the warm-up period ends (default: 300 seconds or 24 hours). Valid values: 0, 300, 3600, 14400, 43200, 86400, 172800
--restart-server
: Upon detecting a failure, only the PBX service is restarted. However, you have the option to configure a full server reboot instead.
Example with custom tolerance and cooldown:
./pbx-monitor-backup.sh --monitor-sip 5060 --tolerance 120 --cooldown 600 --warmup 300
Backup Features
The system can perform automatic daily backups of the PBX directory:
./pbx-monitor-backup.sh --backup
This will:
- Create daily backups at 12:05 AM
- Maintain a 3-day rolling backup history
- Store backups in /var/backups/pbx as zip files
Restore from Backup To restore the system from a previous backup:
./pbx-monitor-backup.sh --restore 2025-05-13
This will:
- Stop the PBX service
- Rename the current PBX directory with a timestamp
- Extract the specified backup
- Start the PBX service
If you're not sure which backups are available, check:
ls -l /var/backups/pbx/
Restart Mode
In most cases, restarting the service should be sufficient (default behaviour)
Choose how to handle service failures i.e restart service (default) or reboot server:
#Restart only the PBX service (default)
./pbx-monitor-backup.sh --monitor-sip 5060 --restart-service --backup
# Reboot the entire server
./pbx-monitor-backup.sh --monitor-sip 5060 --restart-server --backup
Combining Features
You can combine all options to create a complete installation:
./pbx-monitor-backup.sh --monitor-http 80 --monitor-https 443 --monitor-sip 5060 --tolerance 300 --cooldown 600 --warmup 43200 --backup
Expected output after scucesfull installation of the script
- Upon successful installation, the following message will be displayed, containing the version, URL(s) to access the PBX, and the credentials.
=== Vodia PBX Monitoring and Backup Setup Complete ===
Monitoring enabled for:
- SIP port: 5060
- Failure tolerance: 600 seconds
- Cooldown period: 300 seconds
- Initial warm-up period: 86400 seconds
(24 hours)
- Restart mode: service
Automated backup enabled:
- Schedule: Daily at 12:05 AM
- Retention: 3 days rolling
- Backup location: /var/backups/pbx
To restore from backup in the future:
./pbx-monitor-backup.sh --restore YYYY-MM-DD
Log Files and Directories
Main Monitoring Log: /var/log/pbx-monitor/monitor.log
Backup Files: /var/backups/pbx/pbx-backup-YYYY-MM-DD.zip
PBX Directory: /usr/local/pbx/
State Files: /var/log/pbx-monitor/
(contains monitoring state)
Monitoring cron job: /etc/cron.d/pbx-monitor
Backup cron job: /etc/cron.d/pbx-backup
Monitoring script: /usr/local/bin/pbx-monitor.sh
Backup script: /usr/local/bin/pbx-backup.sh