1. Knowledge Base
  2. Zmanda Recovery Manager (ZRM)

Retaining MySQL Binary Logs only as long as needed (ZRM)

This article is for Zmanda Recovery Manager For MySQL (ZRM)

Info Type: Tip

Info Description:

ZRM for MySQL requires that binary logging is enabled on the MySQL server to preform incremental backups. Binary logging has minimal impact on MySQL performance,  but in an active database, the logs can grow to hundreds of gigabytes or even terabytes.

ZRM for MySQL has multiple plugin interfaces to customize the backup and recovery process given the site requirements. One of the plugin interfaces is the post-backup plugin. Because the logs are no longer required after a backup, the post backup plugin can purge the binary logs after the backup.

The following command that purges the old binary logs can be added to the default post backup plugin for ZRM for MySQL:

mysql -uroot -ppasswd -e “purge master logs before date_sub(now(), interval 1 day);�

Another option is to set the  Ã¢â‚¬Å“expire_log_days�   MySQL server parameter. The default value for expire_log_days is to purge never purge logs; by setting this to some number, you can have the MySQL server take care of cleaning up logs.

Caution: Users must be careful in purging binary logs on the master replication server if backups are being done on the master server. If slaves are lagging behind the server more than a day, the binary log purge will cause replication to fail.