• xtrabackup 8.0如何恢复单表


    转自:https://www.jianshu.com/p/c8b9852dcef9

    GreatSQL 8.0.2 InnoDB

    1.备份单表, test.t_user

    /usr/bin/xtrabackup -uroot -p'GreatSQL' -S /data/GreatSQL/mysql.sock --tables='test.t_user' --backup --target-dir=/data/backup
    

    2.恢复备份

    xtrabackup --prepare --export --target-dir=/data/backup
    

    3.创建测试表

    [root@GreatSQL][test02]>CREATE TABLE `t_user` (
        ->   `id` bigint NOT NULL AUTO_INCREMENT,
        ->   `name` varchar(255) DEFAULT NULL,
        ->   `age` tinyint DEFAULT NULL,
        ->   `create_time` datetime DEFAULT NULL,
        ->   `update_time` datetime DEFAULT NULL,
        ->   PRIMARY KEY (`id`),
        ->   KEY `idx_name` (`name`),
        ->   KEY `idx_age` (`age`)
        -> ) ENGINE=InnoDB AUTO_INCREMENT=1091002 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
    Query OK, 0 rows affected (0.16 sec)
    

    4.卸载新表表空间

    [root@GreatSQL][test02]>ALTER table t_user discard tablespace;
    Query OK, 0 rows affected (0.11 sec)
    

    5.拷贝备份的t_user文件

    [root@localhost test]# cd /data/backup/test/
    [root@localhost test2]# cp * /data/GreatSQL/test02/
    [root@localhost test2]# ll
    -rw-r--r-- 1 root root      964 Nov 24 04:12 t_user.cfg
    -rw-r----- 1 root root 18874368 Nov 24 04:10 t_user.ibd
    

    6.挂载新表表空间

    [root@GreatSQL][test02]>ALTER TABLE t_user import tablespace;
    Query OK, 0 rows affected, 1 warning (0.47 sec)
    

    7.查询恢复数据

    [root@GreatSQL][test02]>select count(*) from test02.t_user;
    +----------+
    | count(*) |
    +----------+
    |    91002 |
    +----------+
    1 row in set (0.10 sec)
    # 旧表的数据
    [root@GreatSQL][test02]>select count(*) from test.t_user;
    +----------+
    | count(*) |
    +----------+
    |    91002 |
    +----------+
    1 row in set (0.07 sec)
    
    (Wed Nov 24 21:35:57 2021)[root@GreatSQL][test02]>
    

      

      

  • 相关阅读:
    KMP算法小结
    算法二叉搜索树之AVL树
    算法导论之红黑树的学习
    算法导论小结(一)
    感悟或摘抄
    js中神奇的东西
    简单了解webservice
    用<![CDATA[]]>将xml转义为 纯文本
    简单了解soap协议
    java写webservice接口
  • 原文地址:https://www.cnblogs.com/digdeep/p/16122223.html
Copyright © 2020-2023  润新知