xtrbackup

XtraBackup 是 Percona 公司开发的开源 MySQL 热备份工具,专为 InnoDB/XtraDB 引擎设计,具有零停机备份的核心优势。

备份

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 完整备份
xtrabackup --backup --target-dir=/path/to/backup
# 增量备份
xtrabackup --backup \
--target-dir=/path/to/incremental_backup \
--incremental-basedir=/path/to/base_backup

# 压缩备份
xtrabackup --backup --compress \
--target-dir=/path/to/compressed_backup

# 加密备份
xtrabackup --backup --encrypt=AES256 \
--encrypt-key="your_encryption_key" \
--target-dir=/path/to/encrypted_backup

# 并行备份
xtrabackup --backup --parallel=4 \
--target-dir=/path/to/parallel_backup

# 标准流备份
xtrabackup --backup --stream=xbstream \
> /path/to/backup.xbstream

# 压缩流备份
xtrabackup --backup --compress --stream=xbstream \
> /path/to/backup.xbstream

# 备份指定数据库
xtrabackup --backup --databases="db1 db2" \
--target-dir=/path/to/partial_backup

# 备份指定表
xtrabackup --backup --tables="^db[.]table_" \
--target-dir=/path/to/table_backup

# 限制IOPS
xtrabackup --backup --throttle=10 \
--target-dir=/path/to/throttled_backup

还原

1
2
3
4
5
6
7
8
9
10
11
# 1、 bak_compress.xbstream: 备份文件, /backup/bk_compress: 解压的目录
xbstream -x < bak_compress.xbstream -C /backup/bk_compress
# 2、再次对解压出来的目录进行解压
innobackupex --decompress /backup/bk_compress
# 3、执行apply-log命令
innobackupex --apply-log /backup/bk_compress
# 还有以下参数可以使用--defaults-file=/etc/mysql/xxx.cnf --user=xxx --password=xxx
# 4、执行copy-back命令
innobackupex --defaults-file=/etc/mysql/xxx.cnf --user=xxx --password=xxx --copy-back ./restore/
# 5、授权
chown -R mysql:mysql /data/mysql

qpress: command not found解决办法

官方文档链接 Percona XtraBackup Docs

作者

qrua7

发布于

2025-04-13

更新于

2025-10-28

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×