Backing up MySQL with Innobackupex

Source: Internet
Author: User

#!/bin/bash

# by Gaolongquan


logf= "/root/jiankong_log/rc_mysql_slave_backup.log"

Mkdir-p/home/rc_mysql_backup_tmp && mkdir-p/home/rc_mysql_backup && rm-rf/home/rc_mysql_backup_tmp /*


# All Backup

Innobackupex--defaults-file=/etc/my3308.cnf--user=root--password= ' cat/opt/sql '--host=127.0.0.1--port=3308-- Slave-info/home/rc_mysql_backup_tmp 2> $LogF

echo "============== total take $SECONDS SECONDS to backup! ================ ">> $LogF

# Check backup is right?

grep "innobackupex:completed ok\!" $LogF

If [$?-ne 0];then

echo "$HOSTNAME" |mail-s "MySQL backup Failed" gaolongquan#aaa.com

Fi

#

rsync-aq/home/rc_mysql_backup_tmp//home/rc_mysql_backup/


# clean MySQL old bakcup,keep 3 days

find/home/rc_mysql_backup/-name "' date-d" 3 days Ago "+%y-%m-%d ' *" |xargs RM-RF


# Apply-log, can rsync to new machine, Apply-log Hou Rongliang hui Bian da

File= ' ls/home/rc_mysql_backup_tmp/'

Innobackupex--apply-log--use-memory=1g/home/rc_mysql_backup/"$File" 2>> $LogF

If memory is not enough, do not use the use-memory parameter, if you add a little more, speed up the Apply speed

Backing up MySQL with Innobackupex

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.