Use Xtrabackup to implement Mysql backup _mysql

Source: Internet
Author: User
Tags compact mkdir file permissions mysql backup percona

Download Address: https://www.percona.com/downloads/XtraBackup/

Install Xtrabackup

[Root@node1 ~]# Yum Install Percona-xtrabackup

Full backup

Node One

Modify the configuration file to set a separate table space for each table, which must be set when the database is installed

[Root@node1 ~]# vim/etc/my.cnf
[mysqld]
Innodb_file_per_table=on

Create a backup directory

[Root@node1 ~]# mkdir/backpus/

Backup

[Root@node1 ~]# Innobackupex--user=root/backpus/

Copy to Node 2

[Root@node1 ~]# scp-r/backpus/2016-07-13_20-27-04 192.168.1.114:/root/

Node two

(after the MySQL installation of Node II do not start, after startup due to the generation of initialization files can not be restored)

[Root@node2 ~]# Yum Install Percona-xtrabackup

Move backup files to the/backups directory

[Root@node2 ~]# mkdir/backups/
[root@node2 ~]# mv 2016-07-13_20-27-04//backups/

Organize the backup files

[Root@node2 ~]# Innobackupex--apply-log/backups/2016-07-13_20-27-04/

Restores

[Root@node2 ~]# Innobackupex--copy-back/backups/2016-07-13_20-27-04/

Modify file Permissions

[Root@node2 ~]# chown-r mysql:mysql/var/lib/mysql/*

Incremental backups

modifying data

[root@node1 ~]# MySQL
mariadb [(none)]> use Hellodb;
MARIADB [hellodb]> CREATE TABLE Xxoo2 (id int);
MARIADB [hellodb]> INSERT INTO Xxoo2 values (1), (10), (83);

Incremental backup of previously fully backed up files

[root@node1 ~]# innobackupex --incremental /backpus/ --incremental-basedir=/backpus/2016-07-13_20-27-04

Read-only for full backups, preparing for incremental and full consolidation

[root@node1 ~]# innobackupex --apply-log --redo-only /backpus/2016-07-13_20-27-04/

Merge increment to full

[root@node1 ~]# innobackupex --apply-log --redo-only /backpus/2016-07-13_20-27-04/ --incremental-dir=/backpus/2016-07-13_23-13-25/

View Incremental backup files

[Root@node1 ~]# less/backpus/2016-07-13_23-13-25/xtrabackup_checkpoints 
backup_type = incremental
from_lsn = 1642047
to_lsn = 1646912
last_lsn = 1646912
Compact = 0

View full backup files

[Root@node1 ~]# less/backpus/2016-07-13_20-27-04/xtrabackup_checkpoints
backup_type = full-prepared
from_ LSN = 0
to_lsn = 1646912
last_lsn = 1646912
Compact = 0

Then, if you have a new incremental backup file, you can continue to restore the full backup file when you merge the restore on the full backup file

Note: MySQL access rights, I operate in the process of many errors, are in the MySQL database and the permissions of the group has problems.

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.