When it comes to an empty binary log, it is version specific:
120
in MySQL 5.6
107
in MySQL 5.5
106
in MySQL 5.1
98
in MySQL 4.1/5.0
I have discussed this many times in the DBA StackExchange
In your case, you need to run just one command
SHOW MASTER STATUS;
This tells you the current binary log mysqld is writing to and the postition. It just so happens, the log position is also the filesize.
Here is an example how to check for an empty binlog before launching a backup
MYSQL_USER=root
MYSQL_PASS=rootpassword
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
#
# Find out the MySQL Version
#
SQL="SELECT VERSION()"
VERS=`mysql ${MYSQL_CONN} -ANe$"${SQL}"`
MYSQL_VERSION=`echo "${VERS}" | sed 's/\./ /g' | sed 's/ /./' | awk '{print $1}'`
case "${MYSQL_VERSION}" in
"5.0") EMPTY_BINLOG_SIZE=98 ;;
"5.1") EMPTY_BINLOG_SIZE=106 ;;
"5.5") EMPTY_BINLOG_SIZE=107 ;;
"5.6") EMPTY_BINLOG_SIZE=120 ;;
esac
#
# Get the Current Master Log's Position
#
SQL="SHOW MASTER STATUS"
LOGPOS=`mysql ${MYSQL_CONN} -ANe$"${SQL}" | awk '{print $2}'`
#
# Compare log position to an empty log size
#
OK_TO_BACKUP=0
if [ ${LOGPOS} -eq ${EMPTY_BINLOG_SIZE} ]; then OK_TO_BACKUP=1 ; fi
if [ ${OK_TO_BACKUP} -eq 1 ]; then
...
fi
GIVE IT A TRY !!!
SUGGESTION
If all your tables are using the InnoDB Storage Engine, you can dump the data at a point-in-time, capture the log file and position, and still allow INSERTs, UPDATEs, and DELETEs all at the same time (please do not do any DDL during the backup). When you use mysqldump with the options --single-transaction
and --master-data=2
, it will write the log file/position on line 23.
I just mentioned this 6 days ago : Master/Master/Slave Replication
That way, there is no need to wait for an empty binary log with no application downtime.