From acc50f23f35c35fa9caf25cf40f1e3c5d13ce4c3 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Fri, 14 Jul 2023 17:29:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E9=87=8F=E5=BC=8F=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backUpIncremental.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backUpIncremental.sh b/backUpIncremental.sh index 3ce1b25..e09bb27 100755 --- a/backUpIncremental.sh +++ b/backUpIncremental.sh @@ -14,6 +14,12 @@ LAST_BACKUP=$(cat "$backUpPath/last_backup.txt") LAST_BINLOG=$(echo "$LAST_BACKUP" | awk '{print $1}') LAST_POSITION=$(echo "$LAST_BACKUP" | awk '{print $2}') +# 如果是第一次运行,设置初始值 +if [[ -z "$LAST_BACKUP" ]]; then + LAST_BINLOG="none" + LAST_POSITION="0" +fi + # 获取当前binlog文件名和位置 CURRENT_BINLOG=$(mysql -u$userName -p$password -h$host -e "SHOW MASTER STATUS" | awk '{print $1}') CURRENT_POSITION=$(mysql -u$userName -p$password -h$host -e "SHOW MASTER STATUS" | awk '{print $2}')