xtrabackup备份
Posted lishug
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xtrabackup备份相关的知识,希望对你有一定的参考价值。
#!/bin/bash
#xtrabackup流式压缩热备份
#预配置SSH免密码登陆并确认通过
#远程IP及账户等基础信息
REMOTE_HOST="192.168.31.101"
REMOTE_HOST_SSH_PORT="22"
REMOTE_DB_USERNAME="root"
REMOTE_DB_PASSWORD="szyg@123456"
REMOTE_DB_PORT="3306"
#本地IP及账户等基础信息
LOCAL_HOST="192.168.31.100"
LOCAL_HOST_SSH_PORT="22"
LOCAL_DB_USERNAME="root"
LOCAL_DB_PASSWORD="szyg@123456"
LOCAL_DB_PORT="3306"
#本地数据库存放路径
mysql_PATH="/data/mysql/data"
#本地xtrabackup流式备份数据库暂存路径
BACKUP_PATH="/data/mysql/backup"
#异地xtrabackup流式备份数据库存放路径
REMOTE_BACKUP_PATH="/data/mysql/backup"
###在远程服务器流式备份表空间,传送本地服务器
#使用tar格式备份
#innobackupex --user=${LOCAL_DB_USERNAME} --password="${LOCAL_DB_PASSWORD}" --stream=tar --extra-lsndir=${BACKUP_PATH}/chkpoint /data/mysql/backup/ | gzip | ssh -p${REMOTE_HOST_SSH_PORT} ${REMOTE_HOST} "cat - > ${REMOTE_BACKUP_PATH}/$(date +%F)_full.tar.gz"
#使用xbstream格式备份
innobackupex --user=${LOCAL_DB_USERNAME} --password="${LOCAL_DB_PASSWORD}" --stream=xbstream --extra-lsndir=${BACKUP_PATH}/chkpoint /data/mysql/backup/ | gzip | ssh -p${REMOTE_HOST_SSH_PORT} ${REMOTE_HOST} "cat - > ${REMOTE_BACKUP_PATH}/$(date +%F)_full.xbstream.gz"
增量:
innobackupex --user=${LOCAL_DB_USERNAME} --password="${LOCAL_DB_PASSWORD}" --incremental --stream=xbstream --extra-lsndir=${BACKUP_PATH}/chkpoint --incremental-basedir=${BACKUP_PATH}/chkpoint /data/mysql/backup/ | gzip | ssh -p${REMOTE_HOST_SSH_PORT} ${REMOTE_HOST} " cat - > ${REMOTE_BACKUP_PATH}/$(date +%F)_incre.xbstream.gz"
以上是关于xtrabackup备份的主要内容,如果未能解决你的问题,请参考以下文章