Common operations are performed on monitor1, but the data on monitor2 must be updated at any time. However, when the interval is large, it is irrelevant that the script requires local backup and remote backup, at the same time, some data updated by monitor2 is stored. The detailed script code for Nagios mysql backup is as follows:
The Nagios mysql backup script is as follows:
#! /Bin/bash
Date = 'date + % Y % m % d _ % H % m'
BACK_PATH =/opt/data/var/nagios_bak
File11_nagios_etc_1_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
After Nagios mysql is backed up, write the script to crontab.
Add one sentence
1 */2 ***/home/admin/bin/backup_nagios.sh
The entire Nagios mysql backup is complete.
- MySQLdump Incremental backup, full backup, and recovery
- Open-Source Monitoring Project Nagios derivative new project ICINGA is more community-oriented
- O & M monitoring Nagios serialization 3: deploying and configuring the Nagios Service
- Common commands for operating mysql in CentOS
- Use JDBC to connect to the MySQL database on the Ubuntu jsp platform