How to back up Nagios mysql
This article is about how to back up Nagios mysql. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The Nagios mysql backup script is as follows:
#! / bin/bash
Date= `date +% Y% m% dudes% H% M`
BACK_PATH=/opt/data/var/nagios_bak
FILE1=nagios_etc_$date.tar.gz
FILE2=mysql_bakcup_$date.sql
Tar-czf $BACK_PATH/$FILE1 / opt/nagios/etc 1 > / dev/null 2 > / dev/null
Cp $BACK_PATH/$FILE1 / data/var/.
Mysqldump-uroot-ppasswd db > / data/var/$FILE2
Scp $BACK_PATH/$FILE1 monitor2:/opt/data/var/nagios_bak/. 1 > / dev/null 2 > / dev/null
Ssh monitor2 "rm-rf / usr/local/nagios/etc/" 1 > / dev/null 2 > / dev/null
Scp-rp / usr/local/nagios/etc monitor2:/usr/local/nagios/. 1 > / dev/null 2 > / dev/null
Ssh monitor2 "chown-R admin.admin / usr/local/nagios/etc/;/etc/init.d/nagios restart" 1 > / dev/null 2 > / dev/null
Write the script to crontab after Nagios mysql backup
Add a sentence
1 * / 2 * / home/admin/bin/backup_nagios.sh
Thank you for reading! This is the end of the article on "how to back up Nagios mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!