未加星标

Automation Script For Percona Xtrabackup FULL/Incremental

字体大小 | |
[数据库(mysql) 所属分类 数据库(mysql) | 发布者 店小二05 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

Automation Script For Percona Xtrabackup FULL/Incremental
Image Source: DigitalOcean

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.

#1 mysqldump

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 mysqldump . Its completely a logical backup tool. It has a wide range of parameters to use while taking backups (like include routines, events, triggers).

Right place to use mysqldump

Use if your databases are less than 20GB. Because the restore process will take more time. This will affect your RTO.

Advantages: 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. Drawbacks: Backup is multi-thread, but not restore. Its still a single thread process. No incremental backup feature. Restoration takes more time for large backups. #2 mydumper/myloader

This is an opensource tool and DBAs are using this for dump the huge databases. It has inbuild multi-thread dump and restore feature. This is the pioneer for mysql’s multi thread dump. It supports snapshot consistency. So it’ll provide the accurate binlog file and its position.

The right place to use mydumper/myloader

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

Advantages: Multi-thread backup and restore. Supports for Incremental backups. Log the binlog info, 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. Drawbacks: This is also a logical dump. So it needs to scan the complete tables. Performance degrade during the backup. No checksum. #3 Percona Xtrabackup :

This is my favourite opensource tool from Percona. This is also supports incremental backup. The main reason is its very fast since its logical backup. Instead of reading my story just go through this Doc link and see its features.

You can use this to backup >20GB databases to TB or PB.

Advantages: Multi-thread Super fast Compression Checksum Encryption Master/Slave binlog info. Directly restore the backups to AWS Aurora. Drawback: Not much, I’ll update this section if I found something :stuck_out_tongue: 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 bigzaqui at 2013. But I replaced innobackupex with Xtrabackup and few more changes.

Parameters needs to change: -u sqladmin Mysql user to take the dump. Replace with -u your_user 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 binlog info. So you can setup a new replica for the Master Server. You can remove this if you are not using slave to take backup. --compress-threads=4,---parallel=4 The 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 mysql data directory. If you added [xtrabackup] parameters in my.cnf file , then no need to mention this.

本文数据库(mysql)相关术语:navicat for mysql mysql workbench mysql数据库 mysql 存储过程 mysql安装图解 mysql教程 mysql 管理工具

代码区博客精选文章
分页:12
转载请注明
本文标题:Automation Script For Percona Xtrabackup FULL/Incremental
本站链接:https://www.codesec.net/view/628073.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(mysql) | 评论(0) | 阅读(122)