Incremental backup and restore of MySQL via Innobackupex

Source: Internet
Author: User

Backup

Incremental backups are based on a full backup, so we need to do a full backup first:

Innobackupex--password=test/backup/

Note: Test is the password for the root user of my MySQL service,/backup/is the directory I used to store the backup files.

After executing the command, a timestamp directory is generated under the/backup/directory, which in my case is/backup/2016-09-20_14-45-26/.

Incremental backup for the first time:

Innobackupex--password=test--incremental/backup/--incremental-basedir=/backup/2016-09-20_14-45-26/

Note: The--incremental-basedir parameter of the first backup should point to the timestamp directory of the full backup.

After executing the command, a timestamp directory is generated under the/backup/directory, which in my case is/backup/2016-09-20_14-58-01/.

Second Incremental backup:

Innobackupex--password=test--incremental/backup/--incremental-basedir=/backup/2016-09-20_14-58-01/

Note: The--incremental-basedir parameter of the second backup should point to the timestamp directory of the first incremental backup.

After executing the command, a timestamp directory is generated under the/backup/directory, which in my case is/backup/2016-09-20_14-58-30/.

In order to achieve the experimental results, the reader is advised to make additions and deletions to the database before each incremental backup in order to observe the restore effect.

Restores

Stop the MySQL service and empty the data directory:

Service Mysqld Stop
rm-rf/mysql/*

Consolidate full and incremental backups:

Innobackupex--apply-log--redo-only/backup/2016-09-20_14-45-26/
Innobackupex--apply-log--redo-only/backup/2016-09-20_14-45-26/--incremental-dir=/backup/2016-09-20_14-58-01/
Innobackupex--apply-log/backup/2016-09-20_14-45-26/--incremental-dir=/backup/2016-09-20_14-58-30/
Innobackupex--apply-log/backup/2016-09-20_14-45-26/

Note: Be sure to consolidate in the order of full backups, first incremental backups, second incremental backups, and do not use the--redo-only parameter when consolidating the last incremental backup.

Start Restore:

Innobackupex--copy-back/backup/2016-09-20_14-45-26/

After the restore succeeds, you will see "Completed ok!" The words.

Modify the owner and host groups of the data directory and start the MySQL service:

Chown-r mysql.mysql/mysql/
Service mysqld Start

The restore of the incremental backup is completed with the above steps.

Warm tips

When restoring, it is recommended that you make a copy backup of the data directory and the backup directory if there is sufficient space.

Incremental backup and restore of MySQL via Innobackupex

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.