Percona XtraBackup(https://www.percona.com/doc/percona-xtrabackup/LATEST/index.html ) MySQL DBA backup database is one of the necessary artifacts, free, open source, support hot standby and preparation. Here's a record of Ubuntu in your local area The installation process of Linux can refer to the official installation documents.( https://www.percona.com/doc/percona-xtrabackup/LATEST/installation.html).
First of all, habitually look at whether there is apt source support, so popular tools indeed have, where the charm of open source ah! ____________ Direct apt installation.
apt-cache search xtrabackup apt-get install percona-xtrabackup
Percona XtraBackup contains a series of tools( https://www.percona.com/doc/percona-xtrabackup/LATEST/manual.html).
①innobackupex
The symbolic linking of the xtrabackup tool, which still supports all the features and syntax of Version 2.2, is now out of date and will be removed from the next major release. (All don't play with this command anymore)
②xtrabackup
A compiled binary package of C program provides backup function of whole MySQL database instance including MyISAM, InnoDB and XtraDB tables. (Luxi is the tool.)
③xbcrypt
Encryption and decryption of backup files.
④xbstream
"xbstream" file format conversion.
⑤xbcloud
Cloud services ("xbstream" file).
After the installation is successful, try running a backup and recovery process. As shown above, use the xtrabackup tool
(https://www.percona.com/doc/percona-xtrabackup/LATEST/backup_scenarios/full_backup.html ) Here is a full backup, and doubling is also on the basis of full backup. With more operations, no extra execution is required.
Create backups
Direct tapping on the command line.
xtrabackup --backup -uroot -p520 --target-dir=/home/student/backup/ Unrecognized character \x01; marked by <-- HERE after <-- HERE near column 1 at - line 1374. 170620 22:56:32 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: not set Error: Unsupported server version: '5.7.18-0ubuntu0.16.04.1'. Please report a bug at https://bugs.launchpad.net/percona-xtrabackup
I went to the official website to check the error report. The reason is that the XtraBackup version installed is too low. https://bugs.launchpad.net/percona-xtrabackup/+bug/1689588 . His face was blurred. Okay, then uninstall and reinstall the latest version of the "deb" package.( https://www.percona.com/downloads/XtraBackup/LATEST/).
xtrabackup --version xtrabackup version 2.3.7 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 40f611f)
Re-execute the backup after the installation is complete, and then OK.apt-get remove --purge percona-xtrabackup wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.7/binary/debian/xenial/x86_64/percona-xtrabackup-24_2.4.7-2.xenial_amd64.deb gdebi percona-xtrabackup-24_2.4.7-2.xenial_amd64.deb
xtrabackup --backup -uroot -p520 --target-dir=/home/student/backup/ ********** (The print is too long and too long to paste the last sentence.) ********** 170620 23:50:45 completed OK!
(2) Recovery preparationcd /home/student/backup/ ; ls -lh //Total dosage 13M -rw-r----- 1 root root 424 6 February 2023:50 backup-my.cnf -rw-r----- 1 root root 502 6 February 2023:50 ib_buffer_pool -rw-r----- 1 root root 12M 6 February 2023:50 ibdata1 drwxr-x--- 2 root root 4.0K 6 February 2023:50 mysql drwxr-x--- 2 root root 4.0K 6 February 2023:50 performance_schema drwxr-x--- 2 root root 4.0K 6 February 2023:50 student drwxr-x--- 2 root root 12K 6 February 2023:50 sys -rw-r----- 1 root root 113 6 February 2023:50 xtrabackup_checkpoints -rw-r----- 1 root root 453 6 February 2023:50 xtrabackup_info -rw-r----- 1 root root 2.5K 6 February 2023:50 xtrabackup_logfile
Before data recovery, there is an essential "prepare" process that needs to act on backed-up data directory files in order to achieve data consistency.
(3) Implementation recoveryxtrabackup --prepare --target-dir=/home/student/backup/ ********** (The print is too long and too long to paste the last sentence.) ********** 170621 00:01:24 completed OK!
Close MySQL, destroy the original data ("datadir") and resume. In this step, it should be noted that after data recovery, all data directories should be grouped under the "mysql" group of users.
mysql> show variables like "datadir"; +---------------+-----------------+ | Variable_name | Value | +---------------+-----------------+ | datadir | /var/lib/mysql/ | +---------------+-----------------+ 1 row in set (0.03 sec)
service mysql stop mv /var/lib/mysql /var/lib/mysql_backup
xtrabackup --copy-back --target-dir=/home/student/backup/ ********** (The print is too long and too long to paste the last sentence.) ********** 170621 00:12:16 completed OK!
ls -l /var/lib/ | grep mysql drwxr-x--- 6 root root 4096 6 21:00:12 mysql drwx------ 6 mysql mysql 4096 6 21:00:07 mysql_backup
chown -R mysql:mysql /var/lib/mysql service mysql start
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | student | | sys | +--------------------+ 5 rows in set (0.00 sec)