In order to save the storage capacity, physical and logical backups in TencentDB for MySQL are to be compressed with qpress and then packed with xbstream offered by Percona.
The open-source Percona XtraBackup can be used to back up and restore databases. This document describes how to use XtraBackup to restore a physical backup file of TencentDB for MySQL instance to a self-built database on CVM.
This document takes a CVM instance running CentOS and a MySQL v5.7 instance as an example.
You can download data backups and log backups of TencentDB for MySQL instances in the console.
Each IP can have up to 10 download links by default, with a download speed limit of 20–30 Mbps each.
wgetto download the file over the high-speed private network.
The example is as follows:Note：
- You can also click Download to download it directly. However, this may take longer.
wgetcommand format: wget -c 'backup file download address' -O custom filename.xb
wget -c 'https://mysql-database-backup-sh-1218.cos.ap-nanjing.myqcloud.com/12427%2Fmysql%2F0674-ffba-11e9-b592-70bd%2Fdata%2Fautomatic-delete%2F2019-12-03%2Fautomatic%2Fxtrabackup%2Fbk_61_156758150%2Fcdb-293fl9ya_backup_20191203000202.xb?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKzxfbLJ1%26q-sign-time%3D1575374119%3B1575417319%26q-key-time%3D1575374119%3B1575417319%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3Dba959757&response-content-disposition=attachment%3Bfilename%3D%22yuan177685_backup_20191203000202.xb%22&response-content-type=application%2Foctet-stream' -O /data/test.xb
xbstream command to unpack the backup file to the target directory.
xbstream -x --parallel=2 -C /data/mysql < /data/test.xb
- The target directory
/data/mysqlis used as an example in this document. You can replace it with the directory you actually use to store the backup file.
/data/test.xbwith your backup file.
The unpacking result is as shown below:
wget -d --user-agent="Mozilla/5.0 (Windows NT x.y; rv:10.0) Gecko/20100101 Firefox/10. http://www.quicklz.com/qpress-11-linux-x64.tar
If an error is displayed during the
wgetdownload, you can go to QuickLZ's official website to download qpress locally and upload it to the Linux CVM instance. For more information, see Uploading Files from Linux or MacOS to Linux CVM via SCP.
tar -xf qpress-11-linux-x64.tar -C /usr/local/bin source /etc/profile
.qpfiles in the destination directory by running the following qpress command:
xtrabackup --decompress --target-dir=/data/mysql
/data/mysqlis the target directory where the backup file was previously stored. You can replace it with the directory you actually use.
--remove-originaloption is supported only in Percona Xtrabackup v2.4.6 and later.
xtrabackupwon't delete the original files during decompression by default. If you want to delete them upon the completion of decompression, add the
--remove-originalparameter to the above command.
After a backup file is decompressed, you need to execute the "apply log" operation by running the following command.
xtrabackup --prepare --target-dir=/data/mysql
If the execution result contains the following output, it means that the preparation succeeded.
Run the following command to open the
The target directory
/data/mysqlis used as an example in this document. You can replace it with the directory you actually use.
Given the existing version issues, the following parameters need to be commented out from the extracted file
Modify file attributes and check whether files are owned by the
chown -R mysql:mysql /data/mysql
mysqld_safe --defaults-file=/data/mysql/backup-my.cnf --user=mysql --datadir=/data/mysql &