xtrabackup 远程流备份脚本

一、xbstream 流,本地文件夹能够本身建立,异地文件夹必须存在linux

 innobackupex --host=127.0.0.1  --post=3306 --stream=xbstream  --compress /root/backup/ | ssh root@192.168.56.15 "xbstream -x -C /tmp/"

二、xbstream 流,对端机器须要解压并清理压缩文件bash

192.168.56.15
xtrabackup --decompress --target-dir=/tmp/
find /tmp/ -name "*.qp" |xargs  rm -f

三、xbstream 流对端须要安装软件ssh

3.1 xtrabackupide

3.2 qpress-11-linux-x64.tarpost


四、脚本,周一全备,其它都是增备spa

[root@es1 chkpoint]# cat backup.sh
#!/bin/bash

[root@es1 chkpoint]# cat backup.sh 
LOCALDIR=/data/backup
CHECKPIONTDIR=$LOCALDIR/chkpoint
REMOTEDIR=/tmp/


WEEKDAY=`date +%u`
INTERVARNUM=`expr $WEEKDAY - 1`
TISHWEEKFULL=`date -d "$INTERVARNUM day ago" +%F`
TODAY=`date +%F`

ssh root@192.168.56.19 "mkdir -p /$REMOTEDIR/$TISHWEEKFULL"
ssh root@192.168.56.19 "mkdir -p /$REMOTEDIR/$TISHWEEKFULL/$TODAY"


if [ ! -f $CHECKPIONTDIR/xtrabackup_checkpoints ] ;then

echo "没有lsn信息,开始一次全备"

innobackupex --host=127.0.0.1 --history  --post=3306 --stream=xbstream   --compress --extra-lsndir=$CHECKPIONTDIR  $LOCALDIR |ssh root@192.168.56.19 "xbstream -x -C /$REMOTEDIR/$TISHWEEKFULL/"
exit 1
fi


case $WEEKDAY in
#判断变量WEEKDAY的值
    "1")

    innobackupex --host=127.0.0.1 --history  --post=3306 --stream=xbstream   --compress --extra-lsndir=$CHECKPIONTDIR  $LOCALDIR |ssh root@192.168.56.19 "xbstream -x -C /$REMOTEDIR/$TISHWEEKFULL/"        ;;
    "2")

       innobackupex --host=127.0.0.1  --post=3306 --stream=xbstream  --history     --incremental --extra-lsndir=$CHECKPIONTDIR  --incremental-basedir=$CHECKPIONTDIR   --compress $LOCALDIR | ssh root@192.168.56.19 "xbstream -x -C /$REMOTEDIR/$TISHWEEKFULL/$TODAY"

        ;;
        "3")

       innobackupex --host=127.0.0.1  --post=3306 --stream=xbstream  --history     --incremental --extra-lsndir=$CHECKPIONTDIR  --incremental-basedir=$CHECKPIONTDIR   --compress $LOCALDIR | ssh root@192.168.56.19 "xbstream -x -C /$REMOTEDIR/$TISHWEEKFULL/$TODAY"

        ;;
    "4")

       innobackupex --host=127.0.0.1  --post=3306 --stream=xbstream  --history     --incremental --extra-lsndir=$CHECKPIONTDIR  --incremental-basedir=$CHECKPIONTDIR   --compress $LOCALDIR | ssh root@192.168.56.19 "xbstream -x -C /$REMOTEDIR/$TISHWEEKFULL/$TODAY"

        ;;
        "5")

       innobackupex --host=127.0.0.1  --post=3306 --stream=xbstream  --history     --incremental --extra-lsndir=$CHECKPIONTDIR  --incremental-basedir=$CHECKPIONTDIR   --compress $LOCALDIR | ssh root@192.168.56.19 "xbstream -x -C /$REMOTEDIR/$TISHWEEKFULL/$TODAY"

        ;;
        "3")

       innobackupex --host=127.0.0.1  --post=3306 --stream=xbstream  --history     --incremental --extra-lsndir=$CHECKPIONTDIR  --incremental-basedir=$CHECKPIONTDIR   --compress $LOCALDIR | ssh root@192.168.56.19 "xbstream -x -C /$REMOTEDIR/$TISHWEEKFULL/$TODAY"

        ;;
    "4")

       innobackupex --host=127.0.0.1  --post=3306 --stream=xbstream  --history     --incremental --extra-lsndir=$CHECKPIONTDIR  --incremental-basedir=$CHECKPIONTDIR   --compress $LOCALDIR | ssh root@192.168.56.19 "xbstream -x -C /$REMOTEDIR/$TISHWEEKFULL/$TODAY"

        ;;

esac



五、tar 目前不支持增备,压缩解压须要注意,须要tar -xizvf  *.tar.gzrem

相关文章
相关标签/搜索