Page 1 of 1

Bug in restore_xi.sh

Posted: Wed Mar 10, 2021 9:27 am
by jpm
I am currently working on migrating from a CentOS 6 server to a new CentOS 7. When I run the restore_xi.sh script on the new server, get the error "/usr/local/nagiosxi/scripts/restore_xi.sh: line 388: DROP TABLE IF EXISTS nagiosxi;: No such file or directory", due to an incorrect line in the script. This only matters if you're using a postgresql database, which we are. The offending line reads: mysql -h "$nagiosql_dbserver" --port="$nagiosql_dbport" -u root --password=$mysqlpass < "DROP TABLE IF EXISTS nagiosxi;" which is looking for a file named "DROP TABLE IF EXISTS nagiosxi;" (and incorrectly references table nagiosxi instead of database nagiosxi). The line should read

Code: Select all

mysql -h "$nagiosql_dbserver" --port="$nagiosql_dbport" -u root --password=$mysqlpass <<< "DROP DATABASE IF EXISTS nagiosxi;"
or

Code: Select all

echo "DROP DATABASE IF EXISTS nagiosxi;" | mysql -h "$nagiosql_dbserver" --port="$nagiosql_dbport" -u root --password=$mysqlpass
The backup restored correctly other than that, but it did cause some confusion when attempting to migrate the postgresql DB over to mariadb, since the nagiosxi database wasn't deleted properly during the restore. Just wanted to make sure the team was aware

Re: Bug in restore_xi.sh

Posted: Wed Mar 10, 2021 4:58 pm
by dchurch
Thank you. This is a very old bug you have found, dating back to 2015.

I've got a patch submitted. To anyone having issues with this, the above solution should work for workarounds.