diff --git a/backUpIncremental.sh b/backUpIncremental.sh index 0edc704..4c50142 100755 --- a/backUpIncremental.sh +++ b/backUpIncremental.sh @@ -22,7 +22,7 @@ CURRENT_BINLOG=$(mysql -u$userName -p$password -h$host -N -e "SHOW MASTER STATUS CURRENT_POSITION=$(mysql -u$userName -p$password -h$host -N -e "SHOW MASTER STATUS" | awk '{print $2}') if [[ -z "$LAST_BACKUP" ]]; then - LAST_BINLOG=$CURRENT_BINLOG + LAST_BINLOG="ON.000001" LAST_POSITION="0" fi echo "" @@ -35,8 +35,8 @@ cd $backUpPath #if [ -z "$LAST_BINLOG" ]; then # mysqldump -u $MYSQL_USER -p$MYSQL_PASSWORD -h $MYSQL_HOST $MYSQL_DATABASE > "$BACKUP_DIR/full_backup.sql" #else - echo "docker exec maria /usr/bin/mysqlbinlog -u"${userName}" -p"${password}" -h"${host}" --start-position="${LAST_BINLOG}" --stop-position="${CURRENT_POSITION}" "$LAST_BINLOG" > "${backUpPath}"/"${dbName}"-"${currentTime}".sql" - docker exec maria /usr/bin/mysqlbinlog -u${userName} -p${password} -h${host} --start-position=${LAST_BINLOG} --stop-position=${CURRENT_POSITION} $LAST_BINLOG > ${backUpPath}/${dbName}-${currentTime}.sql + echo "docker exec maria /usr/bin/mysqlbinlog -u"${userName}" -p"${password}" -h"${host}" --start-position="${LAST_POSITION}" --stop-position="${CURRENT_POSITION}" "$LAST_BINLOG" > "${backUpPath}"/"${dbName}"-"${currentTime}".sql" + docker exec maria /usr/bin/mysqlbinlog -u${userName} -p${password} -h${host} --start-position=${LAST_POSITION} --stop-position=${CURRENT_POSITION} $LAST_BINLOG > ${backUpPath}/${dbName}-${currentTime}.sql #fi # 更新上次备份的binlog文件名和位置 echo "$CURRENT_BINLOG $CURRENT_POSITION" > "last_backup.txt"