MySQL backup practices

backupMySQLmysqldump

I have a MySQL master-master replication with second master in read-only mode.
My questions reg backup are:

  1. I have 10 databases so should I take daily backup as one dump containing all the databases, if yes when restoring will I be able to restore each database from the full dump which has all the databases? Or taking one db at a time is the good way to go?

  2. Should I take backup from active master or read-only master? If read-only master is the case, then what if before the replication had broken and the backup has been taken from read-only – it will not have the updated data until the replication is active again right? So backing up from active master is fine?

  3. How to go about backing binary logs since im not aware of it much.? What is the process to take binary log backup.?

Thanks!!

Best Answer

A1.

How large are the databases?

If you need logical backup, you can use mysqldump (--single-transaction, --master-data are some options you need to review and use). For speed, you want to go with mydumper/myloader tool. It will also make sure of taking individual dumps.

Advantage here is you can grab the database you need to restore without having touch other databases of the instance. If you choose to go with mysqldump, you still can use mysqldumpsplitter to extract the tables/databases of your choice to export from full dump.

Alternatively, you might want to use the physical backup using Percona's Xtrabackup which provides hotbackup. Here is a post to setup Xtrabackup using Holland framework.

A2.

Backup from Active Master? No!

If we have replication failure on read-only master than priority is to get it fixed and then take the backup. But try to avoid backsups from Active Master. It's also advised to make sure your backups are stored on a different location other than read-only master!

A3.

Binary log backups provide point-in-time restore. You can store binary logs to a separate partition and have it backedup/snapshot or scripted to copy files to a separate location.

Check out these two articles: 1 & 2

Hope this is helpful!!