The master might be updating the last binary log file based on the MySQL server configuration. In that case, when we download the last binary log file from the list, we will get incomplete data.
One possible solution can be to download all binary logs except the last one.
# converting to array by wrapping with ()
# we will remove the last element of the array later
mysql_binlog_filename=($(mysql -u $dbuser -h $RDS -e "show master logs"|grep "mysql-bin"|awk '{print $1}'))
# we are excluding the last element from mysql_binlog_filename as the master
# may still be updating the binary log
for file in ${mysql_binlog_filename[@]::${#mysql_binlog_filename[@]}-1}
In https://github.com/awslabs/rds-support-tools/blob/main/mysql/rds-binlog-to-s3/rds-binlog-to-s3.sh, we are using "show master logs" to get the master log file names.
The master might be updating the last binary log file based on the MySQL server configuration. In that case, when we download the last binary log file from the list, we will get incomplete data.
One possible solution can be to download all binary logs except the last one.