| Upgrading Nagios XI to Latest Version |
| Server - Nagios |
|
Before you update your Nagios XI server be sure to create a good backup that could be used to recover if there are problems. This article provides you a script that you can use to backup Nagios XI before an upgrade and shows how to perform the upgrade of Nagios. Upgrade Backup Script for XI It is IMPERATIVE that you backup your Nagios XI before you upgrade. You need an excellent backup that you can depend upon. In this example, we are using a script to stop all major services so the best backup can be achieved.
The script is using bzip2 to compress as it creates the best compression, just have to save space on your server. It assumes you have created a /bk partition (modify that if your backup location is different). It does not make sense to backup to the same disk as the disk could go bad. The script also uses a timestamp so that you can go back to a known good date as you will probably want several backups.
Note: Check the names of your databases and the passwords that you are using as they may not match the settings in the example.
#!/bin/bash ##### BackUp Of Nagios Before Upgrade #####
# Timestamp Backups TIMESTAMP=$(date +%Y%m%d_%H%M); echo $TIMESTAMP
service nagiosxi stop service npcd stop service ndo2db stop service nagios stop
mkdir /bk/upgrade_$TIMESTAMP tar cjf /bk/upgrade_$TIMESTAMP/nagios_$TIMESTAMP.tar.bz2 /usr/local/nagios tar cjf /bk/upgrade_$TIMESTAMP/nagiosxi_$TIMESTAMP.tar.bz2 /usr/local/nagiosxi pg_dump -U nagiosxi -c -F p nagiosxi | bzip2 -c > /bk/upgrade_$TIMESTAMP/pg_nagiosxi_$TIMESTAMP.sql.bz2 mysqldump -u root -pnagiosxi nagios | bzip2 -c > /bk/upgrade_$TIMESTAMP/my_nagios_$TIMESTAMP.sql.bz2 mysqldump -u root -pnagiosxi nagiosql | bzip2 -c > /bk/upgrade_$TIMESTAMP/my_nagiosql_$TIMESTAMP.sql.bz2
service nagios start service ndo2db start service npcd start service nagiosxi start
Here is an example of the script running.
./upgrade.sh 20120209_1259 NPCD Stopped. Stopping ndo2db: done. Stopping nagios: .done. tar: Removing leading `/' from member names tar: Removing leading `/' from member names Starting nagios: done. Starting ndo2db: done. NPCD started.
Review the size of the backup to make sure it worked.
ls -l /bk/upgrade_20120209_1259/ total 32804 -rw-r--r-- 1 root root 1533015 Feb 9 13:01 my_nagios_20120209_1259.sql.bz2 -rw-r--r-- 1 root root 33701 Feb 9 13:01 my_nagiosql_20120209_1259.sql.bz2 -rw-r--r-- 1 root root 15534305 Feb 9 13:00 nagios_20120209_1259.tar.bz2 -rw-r--r-- 1 root root 16413210 Feb 9 13:01 nagiosxi_20120209_1259.tar.bz2 -rw-r--r-- 1 root root 18081 Feb 9 13:01 pg_nagiosxi_20120209_1259.sql.bz2
Upgrade Nagios XI
Download the latest version of Nagios to the /tmp directory.
wget http://assets.nagios.com/downloads/nagiosxi/2011/xi-2011r2.1.tar.gz tar zxvf xi-2011r2.1.tar.gz cd nagiosxi/ ./upgrade
That should have you up and running, and have a good backup. It would be a good idea to run the backup again so you have a backup of the current settings. |