溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

xtrabackup 遠(yuǎn)程流備份腳本

發(fā)布時間:2020-07-30 21:01:57 來源:網(wǎng)絡(luò) 閱讀:957 作者:xingzhehxiang 欄目:MySQL數(shù)據(jù)庫

1、xbstream 流,本地文件夾可以自己創(chuàng)建,異地文件夾必須存在

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

2、xbstream 流,對端機(jī)器需要解壓并清理壓縮文件

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

3、xbstream 流對端需要安裝軟件

3.1 xtrabackup

3.2 qpress-11-linux-x64.tar


4、腳本,周一全備,其它都是增備

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

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?"沒有l(wèi)sn信息,開始一次全備"

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



5、tar 目前不支持增備,壓縮解壓需要注意,需要tar -xizvf? *.tar.gz

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI