====== Backup and Restore Procedures ====== {{indexmenu_n>7}} ===== Backup procedure ===== ==== Database backup ==== Firstly, make a backup of the existing database. There are two methods available to make such backup. If a history database is used, perform its backup as well. === Manual backup === Open a terminal window with the appropriate user credentials and enter the following commands (enter the access credentials for the database): mysqldump -u -p | gzip> pandoradb.sql.gz === Pandora FMS Database Backup utility === Pandora FMS allows to [[:en:documentation:pandorafms:monitoring:04_discovery#console_tasks|periodically perform a backup of the database]] that can be programmed in the following ways **Discovery** → **New console task** and selecting from the drop-down menu **Backup Pandora FMS database**. {{ :wiki:pfms-create-new-console-task-backup-db.png }} To create a new database backup: * **Scheduled**: Select the backup frequency, ''Daily'', ''Hourly'', ''Monthly'', with no interval ''Not scheduled'', ''Weekly'' or ''Yearly''. * **Next execution**: Select exactly when the next backup task will start (first select the day and then the hour), from there it willl be executed periodically unless you chose the option ''Not scheduled'' in the previous point. * **Group**: Group the backup task will belong to (or select all ''All'' for all groups). * **Parameters:** **Save to disk in path**: By default it is stored in ''/var/www/html/pandora_console/attachment/backups'' but you may specify any directory to which you have writing and reading rights. Once you finish filling in the fields, click **Create**. By means of **Pandora FMS database backup manager** (menu **Management → Setup → Admin tools → DB Backup Manager**) you may download the backups made, restore them or simply delete them. //If backups have been deleted, for one reason or another, if you have used the Web Console for this purpose//, in each corresponding item **Status Lost** will be checked and you may use **Delete Lost** to permanently delete all backups in that specific status. ==== Configuration files backup ==== In order to backup Pandora FMS's agents and server configuration files, type in: tar -pcvzf pandora_configuration.tar.gz /etc/pandora/*.conf ==== Agent backup ==== The agent folder must also be backed-up. This is very important to keep deployed collections and agent plugins. tar -pcvzf agent.tar.gz /usr/share/pandora_agent ==== Server backup ==== === Server plugins === Server plugin default folder is under /usr/share/pandora_server (the main Pandora FMS's server folder). **Caution**: If you have server plugins placed in other folders, back them up as well. tar -pcvzf pandora_server.tar.gz /usr/share/pandora_server tar -pcvzf my_plugin_folder.tar.gz /home/myuser/my_plugin_folder === Remote configuration === Remote configuration file and collection backup must be performed in order to keep the remote agent's usual performance 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 ==== Later on, perform a console backup, to keep custom images, extensions, and more. tar -pcvzf pandora_console.tar.gz /var/www/html/pandora_console ===== Restore procedure ===== Perform the [[:en:documentation:pandorafms:installation:01_installing|installation]] procedure. ==== Database restore ==== If you use a history database, restore it as well. === Manual restore === Make sure that your database is up and running, and the Pandora FMS's server and agent are shut down. [root@localhost ~]# /etc/init.d/mysqld start Starting mysqld: [ OK ] [root@localhost ~]# /etc/init.d/pandora_server stop Stopping Pandora FMS Server [root@localhost ~]# /etc/init.d/pandora_agent_daemon stop Stopping Pandora Agent. \\ From version NG 754 onwards, [[:en:documentation:pandorafms:installation:06_server_management#manual_startup:shutdown_for_pandora_fms_servers|additional options are available for manual startup and shutdown]] of High Availability (HA) environments.\\ \\ Then, restore the database [root@localhost ~]# gunzip pandora.sql.gz [root@localhost ~]# cat pandoradb.sql | mysql -u root -p pandora Enter password: Furthermore, the recovery can be performed in the following way. mysql –u root –p pandora create database pandora; use pandora; source PATH BACKUP; The database to be created must have the same name as the backed-up database. ==== Configuration file restore ==== First, restore agent and server configuration files: [root@localhost ~]# tar -zxvf pandora_configuration.tar.gz -C / ==== Agent restore ==== Now, restore the agent directory. [root@localhost ~]# tar -zxvf agent.tar.gz -C / ==== Server restore ==== === Server plugins === Restore the Pandora FMS server main folder, and every other plugin folder that you may have. [root@localhost ~]# tar -zxvf pandora_server.tar.gz -C / [root@localhost ~]# tar -zxvf my_plugin_folder.tar.gz -C / === Remote configuration === Remote configuration file and collection restore must be performed in order to keep the remote agent's usual performance. [root@localhost ~]# tar -zxvf collections.tar.gz -C / [root@localhost ~]# tar -zxvf md5.tar.gz -C / [root@localhost ~]# tar -zxvf remote_agents_conf.tar.gz -C / ==== Console restore ==== Next, restore the console to keep your custom images, extensions, and more. [root@localhost ~]# tar -zxvf pandora_console.tar.gz -C / ==== Starting Pandora FMS server and agent ==== The last step is to start the Pandora FMS server, and agent. [root@localhost ~]# /etc/init.d/pandora_server start [root@localhost ~]# /etc/init.d/pandora_agent_daemon start [[en:documentation:start|Go back to Pandora FMS documentation index]]