Detailed script code for Nagios mysql backup

Source: Internet
Author: User
Tags mysql backup

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.

  1. MySQLdump Incremental backup, full backup, and recovery
  2. Open-Source Monitoring Project Nagios derivative new project ICINGA is more community-oriented
  3. O & M monitoring Nagios serialization 3: deploying and configuring the Nagios Service
  4. Common commands for operating mysql in CentOS
  5. Use JDBC to connect to the MySQL database on the Ubuntu jsp platform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.