modifying backup script to include remote db

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
benhank
Posts: 1264
Joined: Tue Apr 12, 2011 12:29 pm

modifying backup script to include remote db

Post by benhank »

hello guys!
Quick question:
why is it snowing in mass in spring????? lol ok ok the real question:

I have moved my db to a remote server using the instructions found here (this is xi ver 1024 which still uses postgresql):

Code: Select all

https://assets.nagios.com/downloads/nagiosxi/docs/Offloading_MySQL_to_Remote%20Server.pdf
now I want to modify the script found in:

Code: Select all

/usr/local/nagiosxi/scripts/backup_xi.sh
so that it pulls the remote db into the backup.
I modified the lines

Code: Select all

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=$?
and

Code: Select all

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=$?
to

Code: Select all

mysqldump -h [b]REMOTEDB LOCATION[/b]  $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=$?
and

Code: Select all

mysqldump -h [b]REMOTEDB LOCATION[/b]  $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=$?
that should work right? a little scared to run it before I make sure it wont mess anything up =D
Proudly running:
NagiosXI 5.4.12 2 node Prod Env 2500 hosts, 13,000 services
Nagiosxi 5.5.7(test env) 2500 hosts, 13,000 services
Nagios Logserver 2 node Prod Env 500 objects sending
Nagios Network Analyser
Nagios Fusion
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: modifying backup script to include remote db

Post by tmcdonald »

benhank wrote:this is xi ver 1024 which still uses postgresql
You did what now? That's not a version I recognize.

Speaking of versions, I am pretty sure that any recent version of XI is going to have remote backup in the scripts already.
Former Nagios employee
User avatar
benhank
Posts: 1264
Joined: Tue Apr 12, 2011 12:29 pm

Re: modifying backup script to include remote db

Post by benhank »

typo madness it snowed in spring over here my mind was shovel shocked lol.

I did'nt know that.
ok then i'll give the default one a shot. now that you mention it, that backup script will back up the cfg files that have been modded with the settings for the remote db, maybe ill just exclude those files from the back up.
Proudly running:
NagiosXI 5.4.12 2 node Prod Env 2500 hosts, 13,000 services
Nagiosxi 5.5.7(test env) 2500 hosts, 13,000 services
Nagios Logserver 2 node Prod Env 500 objects sending
Nagios Network Analyser
Nagios Fusion
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: modifying backup script to include remote db

Post by tmcdonald »

Yea, if you back up a system with a remote DB it will grab all the db info but it will also assume that the new server is offloaded when you do the restore, so I'd either take care of that before the restore or do like you did and hack up the script a bit.
Former Nagios employee
User avatar
benhank
Posts: 1264
Joined: Tue Apr 12, 2011 12:29 pm

Re: modifying backup script to include remote db

Post by benhank »

ok you can lock the thread and thanks!
Proudly running:
NagiosXI 5.4.12 2 node Prod Env 2500 hosts, 13,000 services
Nagiosxi 5.5.7(test env) 2500 hosts, 13,000 services
Nagios Logserver 2 node Prod Env 500 objects sending
Nagios Network Analyser
Nagios Fusion
Locked