What is the best backup method for MySQL 8.0?

This is Onikai (@fat47) from the Service Reliability Group (SRG) of the Technology Division.
#SRGThe Service Reliability Group primarily provides comprehensive support for the infrastructure surrounding our media services, focusing on improving existing services, launching new ones, and contributing to open-source software (OSS).
This article is located within SRG.DBWGThe DB Working Group is releasing database-related materials that it provides to the entire company.
I hope this is of some help.
 

Introduction


MySQL 8.0 offers various backup methods, but the question remains: which one is the best to use?

conclusion


💡
Logical backup and restore isMySQL Shell Dump UtilityThis is the fastest. For physical backup and restore, there is almost no difference in speed between XtraBackup and CLONE PLUGIN. XtraBackup isMySQL 8.0.29 and laterSoMajor constraintsBe careful as this has happened.
 

Backup methods


There are several ways to perform a full backup, including the following:
  • mysqldump
  • mysqlpump
  • Percona XtraBackup
  • MySQL Shell Instance Dump Utility and Dump Loading Utility
  • CLONE PLUGIN

mysqldump

The mysqldump client is a utility for performing logical backups.
It generates a set of SQL statements that can be executed to reproduce the original schema objects, table data, or both. Output is also possible in other formats, such as CSV or other delimited text.

mysqlpump

It has been included in the MySQL 5.7.8 package since 2015 as a successor to mysqldump.
The differences from mysqldump include improvements such as the ability to display progress and parallel processing.
 

MySQL Shell Instance Dump Utility and Dump Loading Utility

This feature was added in MySQL shell 8.0.21 in 2020.
In addition to performing backups in parallel, restores can also be performed in parallel.
MySQL Shell can also be used in a 5.7 environment.

Percona XtraBackup

This is an open-source backup tool released by Percona.
The backup tools I've mentioned so far are for logical backups,
XtraBackup is a physical backup that copies the database files themselves.
 

CLONE PLUGIN

This is a physical backup feature that was added in MySQL 8.0.17 in 2019.
You can back up your data locally as files or create a remote copy of the target server. Note that backups are limited to tables using the InnoDB storage engine.
 

Backup and Restore Speed ​​Comparison


Database for verification

MySQL Ver8.0.28
Data sizeApproximately 42GB

Graph of results

実行結果の比較
Comparison of execution results
I've included the results graph below. The vertical axis represents seconds.
For logical backups, the MySQL Shell Dump Utility is the fastest for both backup and restore.
For physical backups, there was no significant difference in speed between XtraBackup and CLONE PLUGIN.
The backup and restore commands and execution times for each tool are as follows:

mysqldump

Backup execution results
Execution time: 4 minutes 22 seconds
 
Restore execution results
Execution time: 38 minutes 45 seconds

mysqlpump

Backup execution results
Execution time: 2 minutes 22 seconds
 
Restore execution results
Execution time: 41 minutes 51 seconds

MySQL Shell Instance Dump Utility and Dump Loading Utility

Backup execution results
Execution result: 1 minute 51 seconds
 
Restore execution results
Execution time: 15 minutes 35 seconds
 

Percona XtraBackup

Backup execution results
Execution time: 3 minutes 22 seconds
 
Restore execution results
Execution time: 3 minutes 41 seconds

CLONE PLUGIN

Backup execution results
Execution time: 3 minutes 56 seconds
 
Restore execution results
Execution time: 3 minutes 52 seconds

Which backup tool should I use?


MySQL Shell dump utility
When you need logical backup data, such as when migrating from an on-premises environment to Aurora, I recommend using this MySQL Shell dump utility.
 
XtraBackup
XtraBackup has a long history and comes equipped with various convenient features, allowing you to create a flexible backup plan.
For example, it's possible to directly upload acquired backup data to the object storage of a cloud service using Stream.
However, caution is advised when using XtraBackup with MySQL 8.0.29 or later.
 
Since the default behavior when executing DDL has been changed to INSTANT, completely avoiding this feature would require specifying ALGORITHM=INPLACE/COPY; for every DDL, which is not practical.
If there are tables that have been saved using this INSTANT function, you will not be able to perform a backup using XtraBackup.
To avoid this, as indicated in the error message, you need to execute either OPTIMIZE TABLE or ALTER TABLE ALGORITHM=COPY on the target table.
Backups using XtraBackup should be limited to MySQL 8.0.28 or earlier.
If you are using an environment with version 8.0.17 or later that supports CLONE PLUGIN, you might consider using it.

In conclusion


SRG is looking for new team members. If you are interested, please contact us here.