How to make incremental backups for MySQL
This article mainly explains "how to back up MySQL incrementally". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "MySQL how to incremental backup" it!
It would be nice to add automatic tasks to execute every hour or less.
#! / bin/sh#author RuM#date 2015-07-10BAKDIR=/tmp/mysqlbakBAKDIR_FULL=$BAKDIR/fullBAKDIR_ADD=$BAKDIR/addCONF=/etc/my.cnfpasswd=123456INNOBACKUPEX=/usr/bin/innobackupex
The first execution will make a full and additional backup, and the 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
Fully prepared
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
Incremental backup
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 so far, I believe you have a deeper understanding of "how MySQL incremental backup", might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!