MYSQL 5.6备份实录-- Percona XtraBackup

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MYSQL 5.6备份实录-- Percona XtraBackup相关的知识,希望对你有一定的参考价值。

[[email protected] ~]# cd /usr/local/src

[[email protected] src]# tar zxvf percona-xtrabackup-2.4.4-Linux-x86_64.tar.gz -C /usr/local

[[email protected] src]# cd /usr/local

[[email protected] local]# mv percona-xtrabackup-2.4.4-Linux-x86_64/ xtrabackup

[[email protected] local]# chown mysql -R  xtrabackup/

[[email protected] ~]# su - mysql

[[email protected] ~]$ vi .bash_profile 

PATH=$PATH:/usr/local/xtrabackup/bin

[[email protected] ~]$ source .bash_profile


[[email protected] ~]# mkdir -p /usr/local/mysql/backup

[[email protected] ~]# chown -R mysql /usr/local/mysql/backup


[[email protected] ~]# su - mysql

[[email protected] ~]$ vi full_backup.sh

#!/bin/bash

user='root'

passwd='abcd.1234'

my_config='/etc/my.cnf'

backup_dir='/usr/local/mysql/backup'

if [ -f ~/.bash_profile ];

then

  . ~/.bash_profile

fi

innobackupex  --defaults-file=$my_config --user=$user --password=$passwd $backup_dir


[[email protected] ~]$ chmod a+x full_backup.sh 

[[email protected] ~]$ ./full_backup.sh 

技术分享图片

技术分享图片

[[email protected] ~]$ cd /usr/local/mysql/backup/

[[email protected] backup]$ ll

技术分享图片

[[email protected] backup]$ cd 2018-02-07_15-31-40/

[[email protected] 2018-02-07_15-31-40]$ ll

技术分享图片

[[email protected] ~]$ vi incr_backup.sh

#!/bin/bash  

user='root'

passwd='abcd.1234'

my_config='/etc/my.cnf'

backup_dir='/usr/local/mysql/backup'

last_day=$(date -d "1 days ago" +%Y-%m-%d)

filename=$(find $backup_dir -name "$last_day*" -print|awk -F / '{print $NF}')   

if [ -f ~/.bash_profile ];

then

  . ~/.bash_profile

fi

innobackupex --defaults-file=$my_config --user=$user --password=$passwd --incremental --incremental-basedir=$backup_dir/$filename $backup_dir


[[email protected] ~]$ chmod a+x incr_backup.sh


[[email protected] ~]$ crontab -e

00 3 * * 0 /home/mysql/full_backup.sh>/usr/local/mysql/backup/full_backup.log 2>&1  

00 3 * * 1-6 /home/mysql/incr_backup.sh>/usr/local/mysql/backup/incr_backup.log 2>&1 


[[email protected] ~]$ crontab -l

00 3 * * 0 /home/mysql/full_backup.sh>/usr/local/mysql/backup/full_backup.log 2>&1  

00 3 * * 1-6 /home/mysql/incr_backup.sh>/usr/local/mysql/backup/incr_backup.log 2>&1 


以上是关于MYSQL 5.6备份实录-- Percona XtraBackup的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7.4 x64环境Percona-Server-5.6安装

MYSQL 5.6复制实录--REPLICATION

Linux 下 YUM 安装 Percona Server 5.6

MySQL(Percona Server) 5.6 主从复制

mysql数据库使用xtrabackup工具 实现备份和还原

使用percona-xtrabackup工具对mysql数据库的备份方案