====== Migrating to another system ====== {{indexmenu_n>21}} There can be many reasons to migrate a PFMS server and its Web Console, which are generally on the same real machine or virtual machine ([[:en:documentation:pandorafms:installation:01_installing|Pandora FMS monolith environment]]). //**Possible examples:**// * A new version of Pandora FMS might require a different operating system, for example, migrating from CentOS 7 to Rocky Linux 8 or from Rocky Linux 8 to RedHat Enterprise (RHEL) 8. * It could also be the case of migrating from one web service provider to another: Pandora FMS uses less data than the act of making an //image// of the entire operating system. * In the case of audits or to test new functionalities, it is necessary to have a copy of the main server. ===== Procedure ===== Usually the full path to the PFMS Web Console is /var/www/html/pandora_console and in the following instructions it is abbreviated as ''$CONSOLE_PATH'' . ==== Data Export ==== **1.-** Make a backup of the database of the previous system. There are several steps, open a terminal window with administrator rights (user //root//): * Start by making a logical copy of the database with the following command: mysqldump --single-transaction --max_allowed_packet=512M -u root -p pandora> backup_pandora_X.Y.sql * The previous resulting file ( ''backup_pandora_X.Y.sql'' ) will be compressed with the following data in order to have a single file for the move. For example ''backup_pandora_X.Y.tar.gz'' , compressed format which preserves the intrinsic values of each file. * Compress all existing configuration files in the ''/etc/pandora/*.conf'' directory. * Zip the entire directory and subdirectories of ''$CONSOLE_PATH/attachment/'' . * The custom images and icons in ''$CONSOLE_PATH/images/'' , if any. * Zip the entire ''/var/spool/pandora/data_in/'' directory. * Compress all the [[:en:documentation:pandorafms:technical_reference:05_anexo_server_plugins_development|server plugin]] located in ''/usr/share/pandora_server/util/plugin/'' . If they have one or more //plugins// of the server located in another directory that is not indicated, they must also be compressed. * Compress all dependencies installed on the source server, which are necessary for the proper functioning of //scripts// or //plugins// installed on the source server and are not found on the target server. **Advanced systems will need to fully install the Integrated Development Environments** ( or **Integrated Development Environment IDE** ). * Compress all SSL certificates and custom Apache web server configuration located in ''/etc/httpd/'' , if there are any such file(s). You are solely responsible for the safeguarding of your data. Write down on paper and pencil the procedure you will choose for the data transfer. **Be careful**, use redundancy in terms of backups and procedures with several people helping you in the process. ==== Data Import ==== **2.-** Install the new Pandora FMS system from scratch, we recommend the [[:en:documentation:pandorafms:installation:01_installing|online installation tool]]. **3.-** Close all processes running on the new system, except **mysql**; start with Pandora FMS (starting with version NG 754, there are [[:en:documentation:pandorafms:installation:06_server_management|additional options for manual start and stop]] of HA High Availability Environments): /etc/init.d/pandora_server stop /etc/init.d/pandora_agent_daemon stop /etc/init.d/tentacle_server stop **4.-** To stop the Apache server will depend on the distribution you are using: /etc/init.d/apache2 stop /etc/init.d/httpd stop systemctl stop httpd.service **5.-** Next, send or copy, in the easiest way, the file ''backup_pandora_X.Y.tar.gz'' from the old system to the new one. Unzip the files in their corresponding places. **6.-** Enter **mysql** with user //root//. Access the Pandora FMS database in the new system, by default ''pandora'' and import the database. # mysql -u root -p mysql>use pandora Database changed mysql>source ~/backup_pandora_X.Y.sql //This path will vary depending on the directory where you have the old system backup//, here it is assumed that you have it in your home directory (''$HOME''). **7.-** If you are migrating to a major version, where the database structure changes, this would be the time to run the migration scripts as indicated in the [[:en:documentation:pandorafms:installation:02_anexo_upgrade#update_a_major_version|major version upgrade procedure]]. **8.-** If you have made a distribution change, take into account that the path or ''PATH'' of the Web Console has been modified and in this case there are some fields in the database that have also been changed. modified, such as the ''tconfig'' table and its ''attachment_store'' and ''fontpath'' fields. To modify these fields you must enter these instructions (//query//). The example is for a migration to Rocky Linux 8; in other distributions change the ''path'' of the Apache directory. # mysql -u root -p> use pandora; Database changed> UPDATE tconfig SET value = '/var/www/html/pandora_console/attachment' WHERE token LIKE 'attachment_store';> UPDATE tconfig SET value = '/var/www/html/pandora_console/include/fonts/smallfont.ttf ' WHERE token LIKE 'fontpath'; //These //''PATH'' //must also be taken into account in the server and console configuration files// (''config.php'' and ''pandora_server.conf'' files). **9.-** Once the database has been migrated, you must check if the files ''…/pandora_console/include/config.php'' and ''/etc/pandora/pandora_server.conf'' and the new ones they have the same data in the ''dbname'', ''dbuser'' and ''dbpass'' fields. * //If they are the same go //to **step number 10**. * If they are different, choose only one of the following options: * Option ( a ): Replace the new files with the old ones. * Option ( b ): Copy the data ( ''dbname'', ''dbuser'' and ''dbpass'' ) from the old files to the new ones. * Option ( c ): Grant permissions to the database with the data from the new installation. Assuming that the new installation has these data: ''dbname=pandora'', ''dbuser=pandora1'' and ''dbpass=pandora2'', the example takes the form: # mysql -u root -p> grant all privileges on pandora.* to 'pandora1'@'localhost' identified by 'pandora2';> flush privileges; **10.-** After this, start all the [[:en:documentation:pandorafms:introduction:03_glossary|daemon]] again and you will be able to access the Pandora FMS Console, with all the Agents, Modules, alerts , etc. **11.-** If in the new //host// the IP address or URL have changed, all Agents //**local**// will report to this new system. For Software Agents, you must modify the parameter [[:en:documentation:pandorafms:installation:05_configuration_agents#server_ip|server_ip]] in each of them. **12.-** Use, in [[:en:documentation:pandorafms:complex_environments_and_optimization:01_massive_operations#operaciones_masivasagentes|Operaciones Masivas, editing agents]] to finalize any pending details.