通过innobackupex备份数据库和恢复数据库的命令
1. Create Backup using Percona Xtrabackup
innobackupex --user=root --password=backpassword --host=localhost /tmp/
NOTE: Lets assume the command above creates a backup called /tmp/2018-12-07_03-09-06
2. Prepare backup
sudo innobackupex --apply-log --use-memory=2G /tmp/2018-12-07_03-09-06
3. Transfer backup folder to remote slave server.
scp -rC /tmp/2018-12-07_03-09-06 remote-db-server:/tmp
4. Perform Restoration on Remote Server
service mysql stop
mv /var/lib/mysql /tmp/mysql-old
mv /tmp/2018-12-07_03-09-06 /var/lib/mysql
chmod 755 /var/lib/mysql
chown mysql:mysql -R /var/lib/mysql
5. Create /var/lib/mysql/grastate.dat config file
vim /var/lib/mysql/grastate.dat
sudo chown mysql:mysql -R /var/lib/mysql/grastate.dat
NOTE: add contents to the newly created grastate.dat file from the grastate.dat copy on the MySQL Server where the backup was originally performed.
6. Update newly created grastate.dat seqno value.
cat /var/lib/mysql/xtrabackup_galera_info # copy seqno i.e., digit after ":" e.g, 88103385 from the results below:
9bda690c-d24d-11e6-8944-46d5e753f4b1:88103385
7. Start MySQL
service mysql start