创建完整的压缩备份(xtrabackup)

Creating Compressed Backups

In order to make a compressed backup you’ll need to use the --compress option:

$ xtrabackup --backup --compress --target-dir=/data/compressed/

The --compress uses the qpress tool that you can install via the percona-release package configuration tool as follows:

$ sudo percona-release enable tools
$ sudo apt-get update
$ sudo apt-get install qpress

Note

Enable the repository: percona-release enable-only tools release

If Percona XtraBackup is intented to be used in combination with the upstream MySQL Server, you only need to enable the tools repository: percona-release enable-only tools.

See also

Installing Percona XtraBackup from Repositories

If you want to speed up the compression you can use the parallel compression, which can be enabled with --compress-threads option. Following example will use four threads for compression:

$ xtrabackup --backup --compress --compress-threads=4 \
--target-dir=/data/compressed/

Output should look like this

...
170223 13:00:38 [01] Compressing ./test/sbtest1.frm to /tmp/compressed/test/sbtest1.frm.qp
170223 13:00:38 [01]        ...done
170223 13:00:38 [01] Compressing ./test/sbtest2.frm to /tmp/compressed/test/sbtest2.frm.qp
170223 13:00:38 [01]        ...done
...
170223 13:00:39 [00] Compressing xtrabackup_info
170223 13:00:39 [00]        ...done
xtrabackup: Transaction log of lsn (9291934) to (9291934) was copied.
170223 13:00:39 completed OK!

Preparing the backup

Before you can prepare the backup you’ll need to uncompress all the files. Percona XtraBackup has implemented --decompress option that can be used to decompress the backup.

$ xtrabackup --decompress --target-dir=/data/compressed/

Note

--parallel can be used with --decompress option to decompress multiple files simultaneously.

Percona XtraBackup doesn’t automatically remove the compressed files. In order to clean up the backup directory you should use --remove-original option. Even if they’re not removed these files will not be copied/moved over to the datadir if --copy-back or --move-back are used.

When the files are uncompressed you can prepare the backup with the --prepare option:

$ xtrabackup --prepare --target-dir=/data/compressed/

You should check for a confirmation message:

InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 9293846
170223 13:39:31 completed OK!

Now the files in /data/compressed/ are ready to be used by the server.

Restoring the backup

xtrabackup has a --copy-back option, which performs the restoration of a backup to the server’s datadir:

$ xtrabackup --copy-back --target-dir=/data/backups/

It will copy all the data-related files back to the server’s datadir, determined by the server’s my.cnf configuration file. You should check the last line of the output for a success message:

170223 13:49:13 completed OK!

You should check the file permissions after copying the data back. You may need to adjust them with something like:

$ chown -R mysql:mysql /var/lib/mysql

Now that the datadir contains the restored data. You are ready to start the server.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值