Backup and recovery procedures
Backup Procedure
Database backup
First, a backup of the existing database needs to be performed.
If you use a history database, you must also perform a backup of it.
Manual database backup
First, open a terminal window with the appropriate user credentials. Enter the following commands (provide the database access credentials):
mysqldump -u <pandora_db_user> -p <pandora_db_name> | gzip > pandoradb.sql.gz
This will create a compressed logical backup of the entire Pandora FMS database <pandora_db_name>.
Pandora FMS Database Backup utility
Pandora FMS allows for a database backup periodically that can be scheduled in the left side menu, Management → Discovery → New console task and selecting from the drop-down list the option Backup Pandora FMS database:
To create a new database backup:
Scheduled: Select the frequency with which the backup task will run: daily Daily, hourly Hourly, monthly Monthly, without any periodicity Not scheduled, weekly Weekly, or yearly Yearly.
Next execution: Select exactly when the backup task will start (first choose the day and then the time); from then on it will be done periodically unless you have chosen the Not scheduled option in the previous point.
Group: Group to which the backup task will belong (or select All for all groups).
In Parameters there are two elements that are important to take into account:
Save to disk in path: By default, it is stored in /var/www/html/pandora_console/attachment/backups but you can specify any directory in which you have read and write permissions (you must know the exact path since it only has a simple text box for it).
Active backups: To save storage space, by default, the last three backups performed will be kept.
Once you have finished filling out the fields, click the Create button to save.
Through the Pandora FMS database backup manager (menu Management → Setup → Admin tools → DB Backup Manager), you will be able to download the backups performed, restore said backups, or simply delete them. In the event that backups have been deleted, for one reason or another, without using the Web Console for it, the corresponding item will mark a “lost” state (Status Lost) and the Delete Lost button can be used to permanently delete all backups in that specific state.
Configuration file backup
First, open a terminal window with the appropriate user credentials. The code shown in this topic uses the root user; otherwise, prepend the sudo command to each execution line. To backup Pandora FMS agents and server configuration files:
tar -pcvzf pandora_configuration.tar.gz /etc/pandora/*.conf
Agent Backup
You also need to back up the Agent file. It is very important to keep the already deployed collections and Agent plugins.
tar -pcvzf agent.tar.gz /usr/share/pandora_agent
Server Backup
Server plugins
The default file for server plugins is in /usr/share/pandora_server (the main directory for the Pandora FMS Servers).
tar -pcvzf pandora_server.tar.gz /usr/share/pandora_server
If you have server plugins located in other directories, you should back them up as well.
tar -pcvzf my_plugin_folder.tar.gz /home/my_user/my_plugin_folder
Remote configuration
A backup of remote configuration files and collections must be executed to maintain the correct behavior of the remote Agent.
tar -pcvzf collections.tar.gz /var/spool/pandora/data_in/collections tar -pcvzf md5.tar.gz /var/spool/pandora/data_in/md5 tar -pcvzf remote_agents_conf.tar.gz /var/spool/pandora/data_in/conf
Console Backup
Finally, run a backup of the PFMS Web Console. This way, custom images, extensions, etc., can be preserved.
tar -pcvzf pandora_console.tar.gz /var/www/html/pandora_console
Recovery Procedure
Perform the installation procedure.
Database Recovery
If you use a history database, you must perform a recovery of it as well.
Manual Recovery
Make sure your database is up and running, and that the Pandora FMS Server and the local EndPoint are stopped.
systemctl start mysqld Starting mysqld: [ OK ] systemctl stop pandora_server Stopping Pandora FMS Server systemctl stop pandora_agent_daemon Stopping Pandora Agent.
From version NG 754 onwards, additional options for manual start and stop of High Availability (HA) environments are available.
Decompress and import the database.
The database name (<pandora_db_name>) must be the same as the one the backup was made from.
gunzip pandora.sql.gz cat pandora.sql | mysql -u root -p <pandora_db_name>
Additionally, recovery can be performed in the following way:
mysql -u root -p <pandora_db_name>
The database name (<pandora_db_name>) must be the same as the one the backup was made from.
CREATE DATABASE <pandora_db_name>; USE <pandora_db_name>; SOURCE PATH_BACKUP;
Configuration file recovery
First, recover the configuration files for the Agents and servers:
tar -zxvf pandora_configuration.tar.gz -C /
Agent recovery
Now, perform the recovery of the EndPoint directory:
tar -zxvf agent.tar.gz -C /
Server recovery
Server plugins
Restore the main Pandora FMS server file:
tar -zxvf pandora_server.tar.gz -C /
And restore any other custom plugin files you may have:
tar -zxvf my_plugin_folder.tar.gz -C /
Remote configuration
Restoring remote configuration files and collections must be performed to maintain the correct operation of the remote Agent.
tar -zxvf collections.tar.gz -C / tar -zxvf md5.tar.gz -C / tar -zxvf remote_agents_conf.tar.gz -C /
Console recovery
Now run a Console recovery to restore custom images, extensions, etc.
tar -zxvf pandora_console.tar.gz -C /
Start Pandora FMS server and EndPoint
The last step is to start the Pandora FMS server and the EndPoint:
systemctl start pandora_server systemctl start pandora_agent_daemon
