Source-Replica Tutorial
Last Update: January 2021
Exercise 4
In this exercise you will: create a streaming backup of your MySQL-DB1
-
4.0 - Ensure xtrabackup is up-to-date
Open a new terminal window and log in to your MySQL-DB1 instance. Refer to exercise #1 as a reminder for the correct SSH syntax.
sudo -i yum -y update percona-xtrabackup*
-
4.1 - Create the backup
Since we are streaming the backup to another host, it does not matter which directory you are currently at; your $HOMEDIR will suffice.
This command will start xtrabackup with appropriate options (make sure to run this as root):
xtrabackup --backup --stream=xbstream --user root --compress \ --compress-threads 4 --parallel 4 --no-version-check | socat - TCP:db2-TX:3306
--backup
- This option says to do a backup.--stream xbstream
- This option tells xtrabackup to send the all of the backup data to stdout. We catch this output with the “pipe” and redirect that output to socat, which in turn, sends the backup data to our other host over port 3306.--user
- Specify the MySQL user with proper privileges.--parallel 4
- This option specifies how many parallel threads we can use to do the backup.--compress
- Compress the backup stream using simple LZ compression. This may help if your backup must stream over a WAN.--compress-threads
- Since we are backing up in parallel, it will help to also compress in parallel.--no-version-check
- Simply prevents xtrabackup from calling home to check if there is a newer version of the binary.
In your MySQL-DB2 instance terminal window, you should see a line for each file as it is copied over and extracted.
Once the backup is completed, you should see “Completed OK!” in your MySQL-DB1 terminal window.