Skip to content

Potential bug in rds-binlog-to-s3.sh as the last binary log might still be updated by the master #84

@vinodpandey

Description

@vinodpandey

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.

mysql_binlog_filename=$(mysql -u $dbuser -h $RDS -e "show master logs"|grep "mysql-bin"|awk '{print $1}')

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions