xtrabackup 恢复单个表【转】
一、安装与备份
1. 下载安装XtraBackup
$wget http://www.percona.com/redir/downloads/XtraBackup/LATEST/binary/tarball/percona-xtrabackup-2.2.5-5027-Linux-x86_64.tar.gz
$tar xf percona-xtrabackup-2.2.5-5027-Linux-x86_64.tar.gz
#cd percona-xtrabackup-2.2.5-Linux-x86_64/bin
#cp * /usr/bin
2. 创建XtraBackup备份用户,只需要RELOAD, LOCK TABLES, REPLICATION CLIENT权限即可
mysql> CREATE USER 'bkpuser'@'localhost' IDENTIFIED BY 's3cret';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'bkpuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
3.建表
Database changed
mysql> CREATE TABLE `export_test` (
-> `a` int(11) NOT NULL,
-> `b` int(11) DEFAULT NULL,
-> `c` int(11) DEFAULT NULL,
-> PRIMARY KEY (`a`),
-> UNIQUE KEY `b` (`b`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into export_test values(1,3,5);
Query OK, 1 row affected (0.00 sec)
mysql> select * from export_test;
+---+------+------+
| a | b | c |
+---+------+------+
| 1 | 3 | 5 |
+---+------+------+
1 row in set (0.00 sec)
4.innobackupex备份
$innobackupex --defaults-file=/db/mysql5.6/my.cnf -user=bkpuser -password=s3cret -socket=/db/mysql5.6/logs/mysql.sock /home/mysqlweb
5. 查看备份大小
$du -sh 2014-10-23_10-23-36/
402M 2014-10-23_10-23-36/
6.准备apply-log
apply-log前的情况
$find . -name 'export_test*'
./export_test.frm
./export_test.ibd
$innobackupex --apply-log --export /home/mysqlweb/2014-10-23_10-23-36
apply-log后,多了exp和cfg文件
$find . -name 'export*'
./export_test.frm
./export_test.ibd
./export_test.exp
./export_test.cfg
二、单表恢复
1.新建表export_test
mysql> CREATE TABLE `export_test` (
-> `a` int(11) NOT NULL,
-> `b` int(11) DEFAULT NULL,
-> `c` int(11) DEFAULT NULL,
-> PRIMARY KEY (`a`),
-> UNIQUE KEY `b` (`b`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.02 sec)
2.丢弃表空间
mysql> ALTER TABLE export_test DISCARD TABLESPACE;
Query OK, 0 rows affected (0.00 sec)
3.拷贝备份目录中的ibd,cfg,exp 到mysql的datadir目录
mysql> system cp /home/mysqlweb/2014-10-23_10-23-36/test/export_test.{ibd,exp,cfg} /db/mysql5.6/data/test
mysql> system ls /db/mysql5.6/data/test/export_test*
/db/mysql5.6/data/test/export_test.cfg /db/mysql5.6/data/test/export_test.ibd
/db/mysql5.6/data/test/export_test.frm
4.导入表空间
mysql> ALTER TABLE export_test IMPORT TABLESPACE;
Query OK, 0 rows affected (0.01 sec)
mysql> system ls /db/mysql5.6/data/test/export_test*
/db/mysql5.6/data/test/export_test.cfg /db/mysql5.6/data/test/export_test.ibd
/db/mysql5.6/data/test/export_test.frm
mysql> select * from export_test;
+---+------+------+
| a | b | c |
+---+------+------+
| 1 | 3 | 5 |
+---+------+------+
1 row in set (0.00 sec)
转自
xtrabackup 恢复单个表 - CSDN博客
https://blog.csdn.net/lwei_998/article/details/40394339
Percona XtraBackup的部分备份与恢复/单库备份/单表备份/指定库备份/指定表备份 - CSDN博客
https://blog.csdn.net/zhu19774279/article/details/49681767
Partial Backups
https://www.percona.com/doc/percona-xtrabackup/2.4/innobackupex/partial_backups_innobackupex.html
Restoring Individual Tables
https://www.percona.com/doc/percona-xtrabackup/2.4/innobackupex/restoring_individual_tables_ibk.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2017-04-13 Linux字符集的查看及修改【转】