Backing Up GUI Configuration: Difference between revisions
m (Festr moved page Backup to Backing Up GUI Configuration) |
(Add restoreGuiTables CLI command as recommended restoration method) |
||
| Line 92: | Line 92: | ||
== How to Restore from a Backup == | == How to Restore from a Backup == | ||
There are two methods to restore your GUI configuration: the recommended CLI method or the manual method. | |||
'''Warning:''' This process will overwrite your existing GUI settings. Perform these steps on a freshly installed GUI or be prepared to lose current configurations. | '''Warning:''' This process will overwrite your existing GUI settings. Perform these steps on a freshly installed GUI or be prepared to lose current configurations. | ||
=== Method 1: Using the restoreGuiTables CLI Command (Recommended) === | |||
The GUI provides a command-line tool to restore configuration tables directly without manually importing SQL files. | |||
;1. Navigate to your GUI directory: | |||
<pre> | |||
cd /var/www/html | |||
</pre> | |||
;2. Restore the configuration tables: | |||
<pre> | |||
php php/run.php restoreGuiTables -t config -f /var/backups/voipmonitor_gui/config_tables-YYYY-MM-DD.sql | |||
php php/run.php restoreGuiTables -t data -f /var/backups/voipmonitor_gui/data_tables-YYYY-MM-DD.sql | |||
</pre> | |||
;3. Restore the Configuration Files: | |||
Extract the backed-up PHP configuration files into your GUI's web root. | |||
<pre> | |||
# Extract the archive, overwriting existing files | |||
tar xzf /var/backups/voipmonitor_gui/config_files-YYYY-MM-DD.tar.gz | |||
</pre> | |||
=== Method 2: Manual MySQL Import === | |||
Alternatively, you can use the `mysql` command-line client to import the saved SQL dumps. | |||
;1. Restore the Database Tables: | ;1. Restore the Database Tables: | ||
<pre> | <pre> | ||
mysql -u your_user -p voipmonitor < /var/backups/voipmonitor_gui/config_tables-YYYY-MM-DD.sql | mysql -u your_user -p voipmonitor < /var/backups/voipmonitor_gui/config_tables-YYYY-MM-DD.sql | ||
| Line 116: | Line 139: | ||
== AI Summary for RAG == | == AI Summary for RAG == | ||
'''Summary:''' This guide provides a comprehensive, step-by-step method for creating automated daily backups of the VoIPmonitor GUI configuration. It clarifies that this process backs up settings, users, and rules, but not the call data (CDRs) or PCAP files. The core of the guide is a robust shell script that uses the GUI's built-in `run.php` command-line tool to export configuration tables, data tables, and PHP configuration files. The provided script also includes an automated cleanup feature to delete backups older than a configurable number of days. The tutorial details how to create this script, make it executable, and schedule it to run daily using a system cron job. | '''Summary:''' This guide provides a comprehensive, step-by-step method for creating automated daily backups of the VoIPmonitor GUI configuration. It clarifies that this process backs up settings, users, and rules, but not the call data (CDRs) or PCAP files. The core of the guide is a robust shell script that uses the GUI's built-in `run.php` command-line tool to export configuration tables, data tables, and PHP configuration files. The provided script also includes an automated cleanup feature to delete backups older than a configurable number of days. The tutorial details how to create this script, make it executable, and schedule it to run daily using a system cron job. The guide includes two restoration methods: the recommended CLI method using `restoreGuiTables` command and the manual method using `mysql` import. | ||
'''Keywords:''' backup, restore, configuration, gui, settings, users, sensors, capture rules, cron, crontab, automation, disaster recovery, `run.php`, `backupGuiTables`, `backupGuiConfigurationFiles`, mysql, import, export | '''Keywords:''' backup, restore, configuration, gui, settings, users, sensors, capture rules, cron, crontab, automation, disaster recovery, `run.php`, `backupGuiTables`, `restoreGuiTables`, `backupGuiConfigurationFiles`, mysql, import, export, migration | ||
'''Key Questions:''' | '''Key Questions:''' | ||
* How do I back up my VoIPmonitor GUI configuration? | * How do I back up my VoIPmonitor GUI configuration? | ||
| Line 125: | Line 148: | ||
* How do I restore my GUI configuration from a backup? | * How do I restore my GUI configuration from a backup? | ||
* What does the `backupGuiTables` command do? | * What does the `backupGuiTables` command do? | ||
* What does the `restoreGuiTables` command do? | |||
* Does this backup include my call recordings (CDRs/PCAPs)? | * Does this backup include my call recordings (CDRs/PCAPs)? | ||
Revision as of 03:37, 4 January 2026
This guide provides a step-by-step method for creating regular, automated backups of your VoIPmonitor GUI's configuration. This includes users, sensors, capture rules, and all other settings configured through the web interface.
Overview
This backup procedure is designed to save only the GUI's configuration data, not the call data (CDRs) or captured PCAP files. It is an essential part of a disaster recovery plan, allowing you to quickly restore a known-good GUI configuration to a new or rebuilt server without backing up terabytes of call data.
The process uses a command-line PHP script included with the GUI to export three types of data:
- Configuration Tables: The core database tables that store settings (e.g., `users`, `sensors`, `filter_ip`).
- Data Tables: Supporting data like chart configurations and saved reports.
- Configuration Files: The PHP configuration files from the GUI directory itself (e.g., `configuration.php`).
Step 1: Create the Backup Script
First, create a shell script that will run the export commands.
- Create and edit the script file
nano /usr/local/sbin/backup_voipmonitor_gui.sh
- Copy and paste the following content into the file
#!/bin/bash
#
# VoIPmonitor GUI Configuration Backup Script
#
# --- Configuration ---
# Set the base directory where backups will be stored
BACKUP_DIR="/var/backups/voipmonitor_gui"
# Set the retention period in days. Backups older than this will be deleted.
RETENTION_DAYS=30
# --- Script Logic ---
# Create the backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
# Set the filename based on the current date
DAY=$(date "+%Y-%m-%d")
FILE_CFG_TABLES="$BACKUP_DIR/config_tables-${DAY}.sql"
FILE_DATA_TABLES="$BACKUP_DIR/data_tables-${DAY}.sql"
FILE_CFG_FILES="$BACKUP_DIR/config_files-${DAY}.tar.gz"
# Path to the GUI's run.php script
RUN_SCRIPT="/var/www/html/php/run.php"
echo "--- Starting VoIPmonitor GUI Backup for ${DAY} ---"
# Export the configuration and data tables as SQL dumps
php "$RUN_SCRIPT" backupGuiTables -t config -f "$FILE_CFG_TABLES"
php "$RUN_SCRIPT" backupGuiTables -t data -f "$FILE_DATA_TABLES"
# Backup the GUI's PHP configuration files into a compressed tarball
php "$RUN_SCRIPT" backupGuiConfigurationFiles -f "$FILE_CFG_FILES"
echo "Backup files created:"
ls -lh "$FILE_CFG_TABLES" "$FILE_DATA_TABLES" "$FILE_CFG_FILES"
# Clean up old backups
echo "--- Cleaning up backups older than ${RETENTION_DAYS} days ---"
find "$BACKUP_DIR" -type f -mtime +"$RETENTION_DAYS" -name '*-*-*-*.sql' -print -delete
find "$BACKUP_DIR" -type f -mtime +"$RETENTION_DAYS" -name '*-*-*-*.tar.gz' -print -delete
echo "--- Backup complete ---"
Step 2: Make the Script Executable
Set the correct permissions so the script can be run.
chmod +x /usr/local/sbin/backup_voipmonitor_gui.sh
You can test the script by running it manually: `/usr/local/sbin/backup_voipmonitor_gui.sh`. It should create three new files in `/var/backups/voipmonitor_gui`.
Step 3: Schedule the Automated Backup with Cron
The final step is to create a cron job to run the script automatically every night.
- Edit the system's crontab file
crontab -e
- Add the following line to the end of the file
This example will run the backup script every day at 3:30 AM.
30 3 * * * /usr/local/sbin/backup_voipmonitor_gui.sh > /var/log/voipmonitor_backup.log 2>&1
- The `> /var/log/voipmonitor_backup.log 2>&1` part redirects all output (both standard and error) to a log file, which is essential for troubleshooting the cron job if it fails.
Save and close the file. The cron daemon will automatically pick up the new schedule.
How to Restore from a Backup
There are two methods to restore your GUI configuration: the recommended CLI method or the manual method.
Warning: This process will overwrite your existing GUI settings. Perform these steps on a freshly installed GUI or be prepared to lose current configurations.
Method 1: Using the restoreGuiTables CLI Command (Recommended)
The GUI provides a command-line tool to restore configuration tables directly without manually importing SQL files.
- 1. Navigate to your GUI directory
cd /var/www/html
- 2. Restore the configuration tables
php php/run.php restoreGuiTables -t config -f /var/backups/voipmonitor_gui/config_tables-YYYY-MM-DD.sql php php/run.php restoreGuiTables -t data -f /var/backups/voipmonitor_gui/data_tables-YYYY-MM-DD.sql
- 3. Restore the Configuration Files
Extract the backed-up PHP configuration files into your GUI's web root.
# Extract the archive, overwriting existing files tar xzf /var/backups/voipmonitor_gui/config_files-YYYY-MM-DD.tar.gz
Method 2: Manual MySQL Import
Alternatively, you can use the `mysql` command-line client to import the saved SQL dumps.
- 1. Restore the Database Tables
mysql -u your_user -p voipmonitor < /var/backups/voipmonitor_gui/config_tables-YYYY-MM-DD.sql mysql -u your_user -p voipmonitor < /var/backups/voipmonitor_gui/data_tables-YYYY-MM-DD.sql
- 2. Restore the Configuration Files
Extract the backed-up PHP configuration files into your GUI's web root.
# Navigate to the GUI's root directory (path may vary) cd /var/www/html/ # Extract the archive, overwriting existing files tar xzf /var/backups/voipmonitor_gui/config_files-YYYY-MM-DD.tar.gz
After restoring both the database and files, your GUI's configuration should be fully recovered.
AI Summary for RAG
Summary: This guide provides a comprehensive, step-by-step method for creating automated daily backups of the VoIPmonitor GUI configuration. It clarifies that this process backs up settings, users, and rules, but not the call data (CDRs) or PCAP files. The core of the guide is a robust shell script that uses the GUI's built-in `run.php` command-line tool to export configuration tables, data tables, and PHP configuration files. The provided script also includes an automated cleanup feature to delete backups older than a configurable number of days. The tutorial details how to create this script, make it executable, and schedule it to run daily using a system cron job. The guide includes two restoration methods: the recommended CLI method using `restoreGuiTables` command and the manual method using `mysql` import. Keywords: backup, restore, configuration, gui, settings, users, sensors, capture rules, cron, crontab, automation, disaster recovery, `run.php`, `backupGuiTables`, `restoreGuiTables`, `backupGuiConfigurationFiles`, mysql, import, export, migration Key Questions:
- How do I back up my VoIPmonitor GUI configuration?
- How can I save all my users, sensors, and settings?
- Is there a script to automatically back up VoIPmonitor settings?
- How do I schedule a daily backup using cron?
- How do I restore my GUI configuration from a backup?
- What does the `backupGuiTables` command do?
- What does the `restoreGuiTables` command do?
- Does this backup include my call recordings (CDRs/PCAPs)?