This is my first post in 2019, and Im starting with a MySQL solution. In MySQL world, implementing a better backup strategy to meet all of your requirement is still a challenging thing. The complexity depends on your RPO and RTO. Percona has many tools to help DBAs in many scenarios.
Xtrabackup is one of the best backup tools to perform a better backup on TeraBytes size of databases. Also, another great feature is it supports Incremental and Differential backup.
There are couple of tools which is available in MySQL world, But due to some restrictions we can’t achieve what we are expecting.
This is a widely used backup tool and most of the DBAs are trust this. This comes with the mysql package. Initially, it was a single thread process but now we have multi-thread in native
Right place to use
Use if your databases are less than 20GB. Because the restore process will take more time. This will affect your RTO.
- Easy to use
- More detailed documentation.
- Multi-Thread (we need to add parameters to perform this)
- Comes with MySQL, so they will fix if any bugs and implementing new features.
- Backup is multi-thread, but not restore. Its still a single thread process.
- No incremental backup feature.
- Restoration takes more time for large backups.
This is an opensource tool and DBAs are using this for dump the huge databases. It has inbuild multi-thread dump and
The right place to use
If you have the databases grater then 20GB to TB/PB. I have used this to dump TB size. If you used this to take dump for a PB size DB using mysqldumper then please comment below 🙂
- Multi-thread backup and restore.
- Supports for Incremental backups.
- Log the
binloginfo, so we can easily built a new slave.
- We can control the number of threads.
- Compression support.
- Include/Exclude tables in backup.
- Split the table into chunks.
- And etc,etc.
- This is also a logical dump. So it needs to scan the complete tables.
- Performance degrade during the backup.
- No checksum.
This is my
You can use this to backup >20GB databases to TB or PB.
- Super fast
- Directly restore the backups to AWS Aurora.
- Not much, I’ll update this section if I found something 😛
Shell Script to Automate Xtrabackup:
Now coming to the automation part. Im using a shell script to automate FULL and Incremental backup also sync them with GCS and S3. This script is already written by
Parameters needs to change:
-u sqladmin– Mysql user to take the dump. Replace with
SECRET='mysql-user-password'– Mysql user’s password.
--history– Im tacking backup activity into a database. If you don’t want to track just remove this.
--slave-info– If you are taking the backup from a slave, it’ll capture the master’s
binloginfo. So you can setupa new replica for the Master Server. You can remove this if you are not using slave to take backup.
--compress-threads=4,---parallel=4The number of threads needs to perform compress. Its a best practice to allocate 30%-40% from the total cores. I have 40core
cpu, so I used 15 threads.
--remove-original– While decompressing a compressed backup, it’ll leave the compressed files. So this will remove compressed files after the extraction process.
BACKUP_DIR=/mysqldump/xtrabackup/– Location for saving the dump.
DATA_DIR=/mysqldata– Location of
data directory. If you mysql added
Run this script:
- FULL Backup –
- Incremental Backup –
- Restore –