MySQL Incremental backup script (Innobackupex)

Source: Internet
Author: User

1 on-line environment sometimes considering the need to do an incremental backup database, so write a simple script

2 Add automatic tasks do it every hour or less.


#!/bin/sh

#author RuM

#date 2015-07-10

Bakdir=/tmp/mysqlbak

Bakdir_full= $BAKDIR/full

bakdir_add= $BAKDIR/add

Conf=/etc/my.cnf

passwd=123456

Innobackupex=/usr/bin/innobackupex

#第一次执行会做一次全备跟增备, subsequent execution will be an incremental backup

If [-F "$INNOBACKUPEX"]

Then

If [-D "$BAKDIR"]

Then

echo "is OK"

Else

mkdir $BAKDIR _full-p

mkdir $BAKDIR _add-p

Fi

# # #全备

files= ' ls $BAKDIR _full '

If [-Z "$files"]

Then

$INNOBACKUPEX--defaults-file= $CONF--user=root--password= $PASSWD $BAKDIR _full

fullname=$ (dir "$BAKDIR _full")

$INNOBACKUPEX--defaults-file= $CONF--user=root--password= $PASSWD--incremental-basedir= $BAKDIR _full/$FULLNAME/-- Incremental $BAKDIR _add

Else

# # #增量备份

addname=$ (ls-lt $BAKDIR _add |sed-n 2p|awk ' {print $9} ')

$INNOBACKUPEX--defaults-file= $CONF--user=root--password= $PASSWD--incremental-basedir= $BAKDIR _add/$ADDNAME/-- Incremental $BAKDIR _add

Fi

Else

echo "is not install Innobackupex"

Fi


This article is from the "believe it or not you" blog, please be sure to keep this source http://312461613.blog.51cto.com/965442/1672969

MySQL Incremental backup script (Innobackupex)

Related Article

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.