Automate of manual backup/restore xi to xi

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dfmco
Posts: 257
Joined: Wed Dec 04, 2013 11:05 am

Automate of manual backup/restore xi to xi

Post by dfmco »

We are beginning a hardware refresh and moving from CentOS to Ubuntu for the base OS. I am planning to use the manual backup/restore process to move over the data from the old machines but I would prefer to automate these tasks. I am looking for a command line way to do the following:
From the core config manager I need to write configs and delete files. How can this be done from the cli?
From there I move over the files which I can easily automate with Ansible file copy module:
scp -r /usr/local/nagios/etc/ user@serverip:/usr/local/nagios/
scp -r /etc/mrtg/conf.d/ user@serverip:/etc/mrtg/
scp -r /var/lib/mrtg user@serverip:/var/lib/
scp -r /usr/local/nagios/share/perfdata user@serverip:/usr/local/nagios/share/
Then I need to run the import configs tool and import in the following order: commands, time, periods, contact templates, etc. How can this import be done from the cli?
Finally I want to write and verify the import. How can this be done from the cli?

Note, there is an import API call but I am not sure how it would work since it looks for files in /usr/local/nagios/etc/import.

Thanks!
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: Automate of manual backup/restore xi to xi

Post by pbroste »

Hello @dfmco

Thanks for reaching out about migration options using cli.

We do provide a support document that covers the migration process. This will provide a good starting point to work from.

The option to copy the database over and then Write/Apply/Verify can all be done via commands. The 'Write' reads from the database to create the 'hosts and services' for your Core Config.
  • If you require 'Delete' the configs (by default the new instance would be empty) you would want to stop the 'nagios.service' (systemctl command nagios.service) and then delete the configs.
  • [list]
  • rm -rf /usr/local/nagios/etc/services
  • rm -rf /usr/local/nagios/etc/hosts/
[*]Write and Apply work on the following api command:[/*] [*]Start the nagios.service[/*]
[*]To verify the configs run the following preflight check:[/*]
  • /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[/list]

Also an option to bring over from the 'backup and restore' script found '/usr/local/nagiosxi/scripts/' and then follow through with the steps listed above. The repair script checks permissions and issues found '/usr/local/nagiosxi/scripts/reconfigure_nagios.sh'.

Please verify with test system to verify that the commands you are applying function as intended.

Thanks,
Perry
Locked