Mysql xtrabackup Incremental Backup

Source: Internet
Author: User

Mysql xtrabackup Incremental Backup mysql Incremental backup policy full backup on Monday, other Incremental backup, according to business needs, set the retention date, such as to retain January. Incremental Backup steps; 1. Create full backup; 2. Create Incremental Backup Based on the full backup directory; 3. The second Incremental backup is based on the first Incremental Backup Directory. The following is the Incremental backup script written today, run on your testing machine for a few days.

#!/bin/shbegintime=`date +"%Y-%m-%d %H:%M:%S"`format_time=`date +"%Y-%m-%d_%H:%M:%S"`week=`date +%w`port=3306#ip=backdir=/backupfile_cnf=/etc/my.cnfuser_name=rootpasswd=out_log=$datadir/xtraback_log_$format_timetime_cost=$backdir/xtraback_time.txtif [ ! -d "$backdir" ]; then      mkdir -p $backdir fi if [ -d "$backdir/rec5" ];then            rm -rf $backdir-bak           mv $backdir $backdir-bak           mkdir $backdir fi#full backup if [ ! -d "$backdir/full" ];then     echo "#####start full backup at $begintime to directory full" >>$time_cost    innobackupex --defaults-file=$file_cnf --no-lock --no-timestamp --user=$user_name --port=3306 $backdir/full 1>$out_log-full 2>&1    tar -zcvf $backdir/full.tar.gz $backdir/full    break;    elif [ ! -d "$backdir/rec0" ];then     echo "######start 0 incremental backup at $begintime to directory rec0" >>$time_cost    innobackupex --default-file=$file_cnf --no-lock --no-timestamp --user=$user_name --port=$port --incremental --incremental-basedir=$backdir/full $backdir/rec0 1> $out_log-rec0 2>&1    break;    elif [ ! -d "$backdir/rec1" ];then      echo "#######start 1 incremental backup at $begintime to directory rec1" >>$time_cost     innobackupex --defaults-file=$file_cnf --no-lock --no-timestamp --user=$user_name --port=port --incremental --incremental-basedir=$backdir/full $backdir/rec1 1>$out_log-rec1 2>&1     break;     elif [ ! -d "$backdir/rec2" ]; then      echo "######start 2 incremental backup at $begintime to directory rec2" >>$time_cost     innobackupex --defaults-file=$file_cnf --no-lock --no-timestamp --user=$user_name --port=port --incremental --incremental-basedir=$backdir/rec1 $backdir/rec2 1> $out_log-rec2 2>&1     break;     elif [ ! -d "$backdir/rec3" ]; then      echo "#######start 3 incremental backup at $begintime to directory rec3" >$time_cost     innobackupex --defaults-file=$file_cnf --no-lock --no-timestamp --user=root --port=port --incremental --incremental-basedir=$/backdir/rec2 $backdir/rec3 1> $out_log-rec3 2>&1     break;     elif [! -d "$backdir/rec4" ];then      echo "########start 4 incremental backup at $begintime to directory rec4" >>$time_cost     innobackupex --defaults-file=$file_cnf --no-lock --no-timestamp --user=root --port=port --incremental --incremental-basedir=$backdir/rec4 1> $out_log-rec4 2>&1     break;     elif [ ! -d "$backdir/rec5" ];then       echo "#######start 5 incremental backup at $begintime to directory rec5" >>$time_cost \      innobackupex --defaults-file=$file_cnf --no-lock --no-timestamp --user=$user_name --port=port --incremental --incremental-basedir=$backdir/rec4 $backdir/rec5 1> $out_log-rec5 2>&1      break;    fi

 

Restore Step 1 shut down instance 2 application logs. If incremental data exists, restore full backup first, and then restore incremental logs one by one 3 copy data to directory 4 modify data file permissions, chown, chmod 5 start

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.