XI restore from backup to new server with external database

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ckiernan
Posts: 31
Joined: Fri Mar 11, 2016 5:17 pm

XI restore from backup to new server with external database

Post by ckiernan »

I am migrating my XI environment to a different data center. My existing installation uses an external database. For the new environment I installed XI on the new server (same OS) and exported the database to match the architecture of the source environment. The restore_xi.sh script does not take this scenario into account. When I try to restore a backup to the new environment It tries to restore to the source database IP. I modified the restore script to point to my new DB but then I run into user permission problems. Before I continue down this road - or resort to a manual migration - I figured I'd ask the experts. Any recommendations?

I'm running version 5.2.9 in both environments.

Thanks,

Chris
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: XI restore from backup to new server with external datab

Post by BanditBBS »

This is how I did it! Let me get you the docs I followed. Look for an edit to this post soon!

My migrate from one host to another:

Code: Select all

Migrate One XI server to a New Server
On New server(RHEL 6.x 64bit)
Make OS changes(ulimit and such)
Install NagiosXI on new server
Configure ramdisk same as old server
Install Oracle Instant client on new server
Modify restore script to skip mysql section
Copy crontab settings
Take VM snapshot!!!
On Old server(RHEL 5.x 64bit)
Modify back script to skip mysql section
Actual moving of data:
Copy over or backup the nagios user home folder on old server
Globally disable notifications on both servers
 Go to admin page and click the button
Shutdown services on old server
service nagios stop
service npcd stop
On old server Run backup_xi.sh
cd /usr/local/nagiosxi/scripts/
./backup_xi.sh –n migratenag –d /var/lib/mysql
Copy backup to new server
scp /var/lib/mysql/migratenag* x.x.x.x:/store/backups/nagiosxi
Disable network on old server in VCenter
On new server run restore_xi.sh
cd /usr/local/nagiosxi/scripts/
./restore_xi.sh /store/migratenag
Assign old server IP to new server
vi /etc/sysconfig/network-scripts/ifcfg-eth0
change x.x.x.x to x.x.x.x
validate correct IP in /etc/hosts
vi /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=x.x.x.x
NETMASK=255.255.0.0
Start services on DB Server
service ndo2db start
Reboot new server
Globally enable notifications on new server
Go to admin page and click the button
Set ndo2db to not start on new server
chkconfig ndo2db off
Go in directory " /etc/ld.so.conf.d "
As root (for exemple " sudo nano ", or whatever) add a file named "local.conf "
Type in the path to the cuda library " /usr/lib/oracle/11.2/client64/lib ", and save the file
As root run " /sbin/ldconfig " to update
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
reinstall subcomponents nrpe and nagiosplugins
You can ignore the parts about IP and reinstall subcomponents if the servers are the same OS.

Notes:

Code: Select all

From reading the restore_xi.sh script and from my testing, I have validate that these things are true:
The restore_xi.sh script will use your current city2 DB configuration (localhost) and restore the DB to the localhost.
During the restore it will revert these files that will re-setup your offloaded configuration:
/usr/local/nagios/etc/ndo2db.cfg
/usr/local/nagiosxi/html/config.inc.php
/var/www/html/nagiosql/config/settings.php
It will revert the rest of your config files (nagios.cfg, etc)
It will even revert your restore_xi.sh script and undo any changes that you might want to make to overcome these issues.
At the end of the script it will restart the services and will try to connect to the offloaded DB.
So if you have offloaded DB in the new datacenter too, it should restore to that one. However, it will overwrite all that with the old DB information when restored and then error out when restarting everything at the end.

Code: Select all

So knowing this, here is what you would need to do:
Create a directory that you will copy in any of your configuration files that you want to keep and copy those files in there:
mkdir /mylocalhostconfigs
cp /usr/local/nagios/etc/ndo2db.cfg /usr/local/nagiosxi/html/config.inc.php /var/www/html/nagiosql/config/settings.php /mylocalhostconfigs
Run the restore.
Stop the services:
/etc/init.d/httpd stop
/etc/init.d/npcd stop
/etc/init.d/ndo2db stop
/etc/init.d/nagiosxi stop
/etc/init.d/nagios stop
Copy the files back:
cp /mylocalhostconfigs/ndo2db.cfg /usr/local/nagios/etc/ndo2db.cfg
cp /mylocalhostconfigs/config.inc.php /usr/local/nagiosxi/html/config.inc.php
cp /mylocalhostconfigs/settings.php /var/www/html/nagiosql/config/settings.php
Start the services:
/etc/init.d/httpd start
/etc/init.d/npcd start
/etc/init.d/ndo2db start
/etc/init.d/nagiosxi start
/etc/init.d/nagios start
Hope that helps and/or points ya down the proper path
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
ckiernan
Posts: 31
Joined: Fri Mar 11, 2016 5:17 pm

Re: XI restore from backup to new server with external datab

Post by ckiernan »

Thanks. I'll let you know how I do.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: XI restore from backup to new server with external datab

Post by lmiltchev »

Thanks. I'll let you know how I do.
Sure. We will keep the thread open.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ckiernan
Posts: 31
Joined: Fri Mar 11, 2016 5:17 pm

Re: XI restore from backup to new server with external datab

Post by ckiernan »

I'm up and running. The short of it is I commented out the database portion of the backup and restore scripts and exported/imported the DB manually.

Thanks - you can close this thread.
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: XI restore from backup to new server with external datab

Post by avandemore »

Good to hear your issue is resolved. Please open a new thread if you have further problems.
Previous Nagios employee
Locked