Because of the size of my environment we were advised to store our db on a remote server. This setup is fine and working well.
the problem is that the bundled back up script
does not back up the remote db.
Can you mad scientist evil geniuses show a brutha how to get the script to include the remote db in the backup?
thanks and MUHAHAHAHAH! in advance!
##############################
# BACKUP DATABASES
##############################
echo "Backing up MySQL databases..."
mkdir -p $mydir/mysql
mysqldump -h $cfg__db_info__ndoutils__dbserver -u $cfg__db_info__ndoutils__user --password="$cfg__db_info__ndoutils__pwd" --add-drop-database -B $cfg__db_info__ndoutils__db > $mydir/mysql/nagios.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up MySQL database 'nagios' - check the password in this script!"
exit $res;
fi
mysqldump -h $cfg__db_info__nagiosql__dbserver -u $cfg__db_info__nagiosql__user --password="$cfg__db_info__nagiosql__pwd" --add-drop-database -B $cfg__db_info__nagiosql__db > $mydir/mysql/nagiosql.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up MySQL database 'nagiosql' - check the password in this script!"
exit $res;
fi
# Only backup PostgresQL if we are still using it
if [ $cfg__db_info__nagiosxi__dbtype == "pgsql" ]; then
echo "Backing up PostgresQL databases..."
mkdir -p $mydir/pgsql
if [ -z $cfg__db_info__nagiosxi__dbserver ]; then
cfg__db_info__nagiosxi__dbserver="localhost"
fi
pg_dump -h $cfg__db_info__nagiosxi__dbserver -c -U $cfg__db_info__nagiosxi__user $cfg__db_info__nagiosxi__db > $mydir/pgsql/nagiosxi.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up PostgresQL database 'nagiosxi' !"
exit $res;
fi
else
mysqldump -h $cfg__db_info__nagiosxi__dbserver -u $cfg__db_info__nagiosxi__user --password="$cfg__db_info__nagiosxi__pwd" --add-drop-database -B $cfg__db_info__nagiosxi__db > $mydir/mysql/nagiosxi.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up MySQL database 'nagiosxi' - check the password in this script!"
exit $res;
fi
fi
The important bits are the -h $cfg__db_info__xyz__dbserver for each database getting dumped. If it's not working then that variable isn't getting set correctly, however, if I'm not mistaken ... if that variable isn't getting set correctly then Nagios XI is broken I think it grabs that information from the same exact place all the other code gets it from:
benhank wrote:how do i modify the backup script so that it doesn't backup the db? I think that will solve 1 part of my problem
benhank, your DB should already be getting backed up, I know my offloaded one is being backed up with the default scripts. How are you determining your DB is not?
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
benhank - I just dbl checked myself, my DR server where my nightly backups are rcync'd. I extracted the files and verified data in the nagiosql db is updated with stuff that was only put in last week. So, if yours isn't being backed up, I fear it is a different issue than the script.
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
/store/backups/./restore_xi.sh /store/backups/nagiosxi/1445278732.tar.gz
Could not open input file: /store/backups/import_xiconfig.php
TS=1445279187
Extracting backup to /store/backups/nagiosxi/1445279187-restore...
In /store/backups/nagiosxi/1445279187-restore/1445278732...
Backup files look okay. Preparing to restore...
Shutting down services...
Stopping nagios:. done.
Stopping ndo2db: done.
rm: cannot remove `/usr/local/nagiosxi/var/subsys/npcd.pid': No such file or directory
NPCD was not running.
Restoring directories to /...
Restoring Nagios Core...
Restoring Nagios XI...
Restoring NagiosQL...
Restoring NagiosQL backups...
Restoring NRDP backups...
Restoring MRTG...
Restoring MySQL databases...
ERROR 2005 (HY000): Unknown MySQL server host '-u' (1)
Error restoring MySQL database 'nagios' - check the password in this script!
Normally I would just change the db pw, but I know that in this case we went with all the defaults.
benhank wrote:BB, I think that your solution is the one I am aiming for.
How do you have your script set up? can you pm it to me ?
I just used the scheduled backups in admin menu. Limit to 4 and then on my PROD XI server I have rsync setup to rsync the /store/backups folder to my DR server in a different data center about 2 hours after the backup files get created. I have rsync set to delete files no longer existing on the source
I haven't yet done a restore, so not sure if I would get the same error as you are during a restore attempt. I just know the DB is actually backed up from looking in the archives being rsync'd to the DR server.
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