I have a dedicated server hosting a MySQL database, and want to use replication to have an always up-to-date backup somewhere.

I chose to use Amazon RDS as my replica, and I'm following this guide:

Replication with a MySQL Instance Running External to Amazon RDS

What I fail to understand however, is who/what is supposed to take care of purging binary logs. The only configuration I found is expire_logs_days, which the documentation describes as:

You can also set the expire_logs_days system variable to expire binary log files automatically after a given number of days (...). If you are using replication, you should set the variable no lower than the maximum number of days your slaves might lag behind the master.

Is this the standard procedure DBAs use?

Isn't it possible to have RDS, which is the only replica, purge the logs on the master as soon as it's processed them?

1 Answer 1


Server is responsible to purge their own file. Guess what happens if your master has two slaves and one of it catches up faster deleting logs required for second?!!

So yes expire_logs_days is the way to go. Set that value wisely and let master do its business.

That said why do you want to purge logs? You have purge binary logs to command but I'd still let purging upto master unless disk is critical.

If you want it, then you can script out the manual purging logic: Check all slaves have caught up to latest Purge a logs before the exec_master_log_file.

In my opinion this is absolutely unnecessary unless there some odd requirement that u just can't think about...

  • I've experienced binlogs taking quite a lot of space in the past, up to the point of filling up the disk. Plus, this is on a virtual server, limited in resources, including disk space!
    – BenMorel
    Dec 6, 2015 at 10:41
  • A stript is problematic: The operative phrase is "check all slaves". If you forget to add to the list of "all slaves" when you add a slave, then Oops. If you permanently remove a Slave, then Oops. If the hostname changes when you upgrade a Slave, then Oops.
    – Rick James
    Dec 12, 2015 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.