Page 1 of 1

modifying backup script to include remote db

Posted: Mon Apr 04, 2016 2:53 pm
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

Re: modifying backup script to include remote db

Posted: Mon Apr 04, 2016 4:11 pm
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.

Re: modifying backup script to include remote db

Posted: Tue Apr 05, 2016 8:21 am
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.

Re: modifying backup script to include remote db

Posted: Tue Apr 05, 2016 11:17 am
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.

Re: modifying backup script to include remote db

Posted: Tue Apr 05, 2016 1:31 pm
by benhank
ok you can lock the thread and thanks!