Backing Up and Restoring Nagios XI
Backing Up and Restoring Nagios XI
Backing Up and Restoring Nagios XI
Purpose
This document describes how to backup a Nagios XI installation and restore a Nagios XI
installation from a previously made backup. Backups are an important aspect of administration
and maintenance of your system. They can easily facilitate the migration of a Nagios XI
installation between a virtual server and physical server, and the design of a fail-over or disaster recovery
instance of Nagios XI.
Target Audience
This document is intended for use by Nagios XI Administrators who want to use backups as part of managing
a Nagios XI system.
Backup Overview
The backup script will save a copy of the following components of Nagios XI:
• Nagios Core files (/usr/local/nagios/)
• Nagios XI files (/usr/local/nagiosxi/)
• NagiosQL files (/var/www/html/nagiosql/ and /etc/nagiosql/)
◦ These do not exist on fresh installs of Nagios XI 5.5 or newer
• MRTG files (/var/lib/mrtg/ and /etc/mrtg/)
• NRDP files (/usr/local/nrdp/)
• NagVis files (/usr/local/nagvis/)
• CRON files (in /var/spool/cron/apache)
• Apache config files (in /etc/httpd/conf.d/)
• logrotate config files (in /etc/logrotate.d/)
• MySQL databases (nagios, nagiosql, nagiosxi)
• PostgresQL database (nagiosxi)
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 1 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
◦ Clean installs of Nagios XI from 5.x will have the nagiosxi database created in MySQL.
◦ Upgraded installs will continue to use PostgresQL and the restore script will correctly identify this
The backup script will save backups in the /store/backups/nagiosxi/ directory. Backup names
correspond to the Unix timestamp at the time the backups were created, for example 1479858002.tar.gz.
NOTE 1: The backup script restarts the nagios service at the beginning of the backup to ensure the
retention.dat file is up to date with the latest information. There will be a slight interruption to the
monitoring process when the restart occurs.
NOTE 2: If you changed your MySQL root password to something different than "nagiosxi" (the default), you
will need to edit the script and change the themysqlpass= definition found in the first few lines of the script.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 2 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
You can schedule backups to be stored on a remote location using FTP or SSH. Navigate to Admin >
System Backups > Scheduled Backups and here you will find the FTP and SSH tabs. If you had a remote
location mounted to a directory in the file system you could also use the Local tab to backup to that location.
Further information can be found in this KB article:
https://support.nagios.com/kb/article.php?id=482
Backup Methods
There are multiple methods for creating a backup:
• From the command line
• Using the web interface
◦ Manually created
◦ Scheduled
/usr/local/nagiosxi/scripts/backup_xi.sh
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 3 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
===============
BACKUP COMPLETE
===============
Backup stored in /store/backups/nagiosxi/1479858443.tar.gz
Click the Create Backup button and the backup process will begin. There is no status of the backup process
on this page, you will only know it is completed when the .tar.gz file appears in the list of backups.
Any of the methods allow you to schedule it for Daily, Weekly or Monthly (first day of) along with specifying a
particular time.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 4 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
Any of the methods allow you to define the Backup Limit, this is how many backups you would like to keep
before replacing the oldest backup.
FTP
The FTP method is fairly straight forward and the options do not require explaining.
SSH
The SSH method has similar options as the FTP method however it does allow for different authentication
types:
• Password
◦ Simpler to setup
◦ Less secure
• Public Key
◦ Requires a public key to be used in conjunction with a passphrase
◦ More secure but requires some additional setup steps explained in the next section
Local
The Local method is fairly straight forward, the options do not require explaining. It is recommended that you
save a copy of the backups that are created on an another server or backup medium. There's no point in
having backups if they reside on a disk that just crashed.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 5 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
You now need to copy the Public Key to the remote machine that will be used for the SSH backups. The key
is stored by default on the remote machine in the user's home directory under ./ssh/authorized_hosts.
There are two methods available for copying the public key to the remote machine.
You can click the Show Public Key button which displays
the value of the public key that needs to be placed into
the authorized_hosts file on the remote machine in
the user's home directory under ./ssh/, steps on how to
copy and paste this are not provided here.
You can also copy the key from a terminal session from the Nagios XI server. Executing the command in a
terminal session it is a fool-proof way of ensuring the public key is correctly copied to the remote machine.
In this case the remote machine has a nagios user account and this will be used in the next command.
Establish a terminal session to your Nagios XI server and execute the following commands:
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 6 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
cd /usr/local/nagiosxi/var/keys/
ssh-copy-id -i ssh.xi.1570495238.pub nagios@remote_machine
When you execute the command you'll first see output similar to this:
The authenticity of host 'remote_machine (2001:44b8:3132:25:10:25:5:32)' can't
be established.
ECDSA key fingerprint is 5e:ef:1c:c4:f9:6b:95:29:fd:57:93:44:16:00:aa:e1.
Are you sure you want to continue connecting (yes/no)? Yes
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 7 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
You will need to type the password of the user account on the remote machine.
If it was successful then the output should be similar to:
To confirm that it was successful you can now execute the following command:
The passphrase can be obtained from the Nagios XI Scheduled Backups page by clicking the eye icon next
to the Private Key Password field. After typing it you should be logged in as follows:
This means you have correctly copied the key to the remote server. Type exit to logout of the remote server.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 8 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
The last step is to define the settings on the Nagios XI Scheduled Backups page. You will need to define:
• SSH Server
◦ The address of the remote server
• SSH Port
◦ The port used for SSH, 22 is the default
• SSH Username
◦ This is the username to connect as, explained above
• The Key fields will already be populated
• Remote Directory
◦ The location that backups will be stored in
Once you've populated the field, click the Update Settings button to save the values. The screen will refresh
and will display "Updated scheduled backup settings" at the top of the page.
Once you have completed these steps the SSH backups are now configured to use a Private Key.
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 9 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
Restoring Overview
The restore script for Nagios XI can be used for the following scenarios:
• Restoring a Nagios XI server that died or crashed (on the same server or a different server)
• Migrating Nagios XI from:
◦ Different server types:
▪ Physical to Physical
▪ Physical to Virtual
▪ Virtual to Virtual
▪ Virtual to Physical
◦ Different server versions and architectures, for example:
▪ CentOS 5.x x86 to CentOS 7.x x86_64
▪ CentOS 6.x x86_64 to RHEL 7.x x86_64
▪ CentOS 6.x x86_64 to Ubuntu 18.x x86_64
▪ Note: Additional steps are required when restoring to a different OS family (see below). Migration
is possible between any of our supported distributions and architectures.
Before you restore from a backup, you must make sure that you have performed an installation of Nagios XI
on the target machine you plan on restoring. This ensures that required users, groups, and packages are
setup and installed on the target system.
The version of the fresh install of Nagios XI that you are restoring to needs to match the version of Nagios XI
that the backup was taken from. For example:
The server you are restoring to must have Nagios XI 5.2.2 installed on it
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 10 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
https://assets.nagios.com/downloads/nagiosxi/versions.php
After performing the restore you can then proceed to upgrade to the latest version available.
The restore script will restore the components of Nagios XI as outlined in the Backup Overview section of
this document. If the components exist, they will be deleted and/or overwritten.
The script will destroy any existing configurations and data on the server you are restoring Nagios XI to.
It is important that there is enough free disk space on the server as the restore script will:
• Extract the .tar.gz file to /store/backups/nagiosxi/
• Copy the extracted files to the correct locations
• Remove the extracted .tar.gz folder when the restore completes
NOTE: If you changed your MySQL root password to something different than "nagiosxi" (the default), you will
need to edit the script and change the themysqlpass= definition found in the first few lines of the script.
If you have offloaded your databases to an external MySQL server using our offload procedure:
• The restore script will restore the databases to the offloaded MySQL server as it gathers this information
from the backup file
• In the event that your MySQL server also died, you will need to create a duplicate MySQL server for the
restore script to succeed, as it wants to restore to the server defined in the backup file
◦ Simply follow our the offload procedure to setup the offloaded server with the same IP address,
usernames and passwords
◦ If you don't know these passwords, you can recover these by:
▪ Extract the backup .tar.gz file
▪ In the extracted files you will need to extract the nagiosxi.tar.gz file
▪ In those extracted files locate usr/local/nagiosxi/var/xi-sys.cfg and this file will contain
the usernames and passwords
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 11 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
NOTE: If you have Nagios XI configured with a RAM Disk you need to make sure the system you are
restoring to already has the RAM Disk configured, please refer to the following documentation:
Utilizing a RAM Disk in Nagios XI
To restore a backup of your Nagios XI system from the command line, establish a terminal session to your
Nagios XI server as the root user. Start the restore by running the following script, pointing it to the full
location of the .tar.gz file:
/usr/local/nagiosxi/scripts/restore_xi.sh </full/path/to/backupfile.tar.gz>
Example:
/usr/local/nagiosxi/scripts/restore_xi.sh /store/backups/nagiosxi/1279411912.tar.gz
===============
RESTORE COMPLETE
===============
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 12 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
If you restored Nagios XI to a different server the following additional steps may be required.
Changed IP Address
If the IP Address of your Nagios XI server changed, the following needs to be checked / updated:
• Navigate to Admin > System Config > System Settings and ensure the Program URL and External
URL are correct
• Navigate to Admin > System Config > License Information and ensure the server is licensed
• Reconfigure and agents/clients like NRPE or NSClient++ to allow the new IP address to connect
cd /tmp/
wget https://assets.nagios.com/downloads/nagiosxi/scripts/restore_repair.sh
chmod +x restore_repair.sh
./restore_repair.sh
The script downloads the Nagios XI tarball for the version you have restored and installs a series of
components, this fixes a few minor incompatibilities between the operating systems.
Additionally if you migrated from a 32bit to 64bit machine, you'll have to convert the performance data to XML
and import it into RRD's on the new machine. Please, follow the steps outlined in the KB article below:
https://support.nagios.com/kb/article.php?id=166
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 13 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
Restore Troubleshooting
In certain circumstance the restore can fail, generally the script will give an error message which can highlight
the reason for the failure. After fixing problem re-run the restore script again.
Note: If you changed the themysqlpass= definition in the restore script, you will most likely need to make
that change again as the restore script will have been deleted and restored from the backup.
The most common problem experienced in the restore script is MySQL permission issues:
ERROR 1045 (28000): Access denied for user 'root'@'10.26.5.12' (using password: YES)
Error restoring MySQL database 'nagios' - check the password in this script!
Generally these are resolved by changing the themysqlpass= definition in the restore script to match that of
your root password on your MySQL server.
If you have offloaded your MySQL databases to an external server, you may need to grant the root user
permission to connect to allow the restore to work. The following commands will do just that (these
commands will use mypassword as the example password).
Establish a terminal session to your offloaded MySQL server and execute the following commands:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.26.5.12' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
QUIT;
You will need to change the address 10.26.5.12 to the IP address of your Nagios XI server. After making
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 14 / 15
Updated – October, 2019
The Industry Standard In Infrastructure Monitoring
Finishing Up
This completes the documentation on how to backup and restore Nagios XI.
If you have additional questions or other support related questions, please visit us at our Nagios Support
Forums:
https://support.nagios.com/forum
https://support.nagios.com/kb
1295 Bandana Blvd N, St. Paul, MN 55108 [email protected] US: 1-888-624-4671 INTL: 1-651-204-9102
www.nagios.com
© 2017 Nagios Enterprises, LLC. All rights reserved. Nagios, the Nagios logo, and Nagios graphics are the servicemarks, trademarks, or
registered trademarks owned by Nagios Enterprises. All other servicemarks and trademarks are the property of their respective owner. Page 15 / 15
Updated – October, 2019