增量式备份

This commit is contained in:
zhangkun9038@dingtalk.com 2023-07-15 21:14:28 +08:00
parent 975f2b2507
commit 7b36747e8c

View File

@ -15,17 +15,18 @@ LAST_BINLOG=$(echo "$LAST_BACKUP" | awk '{print $1}')
LAST_POSITION=$(echo "$LAST_BACKUP" | awk '{print $2}')
# 如果是第一次运行,设置初始值
# 获取当前binlog文件名和位置
CURRENT_BINLOG=$(mysql -u$userName -p$password -h$host -N -e "SHOW MASTER STATUS" | awk '{print $1}')
CURRENT_POSITION=$(mysql -u$userName -p$password -h$host -N -e "SHOW MASTER STATUS" | awk '{print $2}')
if [[ -z "$LAST_BACKUP" ]]; then
LAST_BINLOG="0"
LAST_BINLOG=$CURRENT_BINLOG
LAST_POSITION="0"
fi
echo ""
# 获取当前binlog文件名和位置
CURRENT_SBINLOG=$(mysql -u$userName -p$password -h$host -N -e "SHOW MASTER STATUS" | awk '{print $1}')
CURRENT_BINLOG=$(mysql -u$userName -p$password -h$host -N -e "SHOW MASTER STATUS" | awk '{print substr($1, 4)}')
CURRENT_POSITION=$(mysql -u$userName -p$password -h$host -N -e "SHOW MASTER STATUS" | awk '{print $2}')
echo current_binlog $CURRENT_BINLOG
echo current_binPostition $CURRENT_POSITION
# 备份增量变更到文件