A brief introduction: Today we discuss the strategy of incremental backup
Two backgrounds: With the increasing of data volume, the full preparation is unrealistic, so the incremental backup strategy is discussed and tested.
Three specific strategies: 11 weeks to the limit, one day to do the full, other times on a full-time basis for incremental backup
2 week as a boundary, package, then upload to the backup server
Four Specific scripts:
The first part of the parameter variable class
#!/bin/bash
#config
xingqi= ' Date +%w '
Date= ' Date +%y%m%d%h '
dateyst= ' date + '%y%m%d%h "-D" -24hour "'
Disksize= ' Df-h|grep ' 9[0-9]% '
Dirname= "/backup/database"
ip= '/sbin/ifconfig eth0 | grep ' inet addr ' | Cut-d:-f2 | awk ' {print '} ' |cut-d '. '-f 3,4 '
User= "AAA"
Password= "CCC"
Pwd= $dirname
Part II fully prepared
function Fullbackup () {
If [-Z ' $DISKSIZE '];then
Mkdir-p $pwd
filename1= $DATE "_full_" $IP
Innobackupex--defaults-file=/etc/my.cnf--user= $user--password= $password--no-timestamp--socket=/tmp/mysql.sock- -slave-info $pwd/$filename 1 >/dev/null
Sleep 2
Else
echo "The disk is full"
Fi
Part Three first incremental backup
function Incrementalbackup () {
filename1= $DATEyst "_full_" $IP
filename2= $DATE "_incremental_" $IP
If [-Z ' $DISKSIZE '];then
Innobackupex--defaults-file=/etc/my.cnf--user= $user--password= $password--no-timestamp--socket=/tmp/mysql.sock- -slave-info--incremental-basedir= $pwd/$filename 1--incremental $pwd/$filename 2 >/dev/null
Sleep 2
Else
echo "The disk is full"
Fi
}
Part IV Second Incremental backup
function Incrementalbackup_1 () {
filename1= $DATEyst "_incremental_" $IP
filename2= $DATE "_incremental_" $IP
If [-Z ' $DISKSIZE '];then
Innobackupex--defaults-file=/etc/my.cnf--user= $user--password= $password--no-timestamp--socket=/tmp/mysql.sock- -slave-info--incremental-basedir= $pwd/$filename 1--incremental $pwd/$filename 2 >/dev/null
Sleep 2
Else
echo "The disk is full"
Fi
Part V Unified Packaging
function Tarbackup () {
Cd/backup/database
Tar-czf $DATEyst. tar.gz fullfile_xtra/
RM-RF database/
}
Part VI calls
if [$xingqi = 2];then
Tarbackup
Fullbackup
elif [$xingqi = 3];then
Incrementalbackup
echo "Incrementalbackup 1"
elif [$xingqi =1];then
Incrementalbackup_1
Else
Incrementalbackup_1
echo "Incrementalbackup n"
Fi
Five incremental recovery steps
1 Restore full-scale backup first
Innobackupex--apply-log--redo-only Base-dir
2 Recovering an incremental backup 1
Innobackupex--apply-log--redo-only Base-dir--incremental-dir=incremental-dir-1
3 Recovering an incremental backup 2
Innobackupex--apply-log Base-dir--incremental-dir=incremental-dir-2
Six points of attention:
Backup:
1 backup scripts do not generate a timestamp directory because a timestamp directory can increase the difficulty of scripting
2 Backup scripts to modify some parameters can be used, based on the week to determine whether to perform incremental or full-scale backup, the full amount of backup before the previous backup full package
Restores
1 Full-volume recovery + incremental recovery can be flexibly coordinated, full-volume recovery is the basis to remember
2 incremental recovery of the selected target cannot be added read-only
Seven, it's almost done.
MySQL 35th article ~xtarbackup incremental backup and policy