Skip to content

[Feature Request]: mo-dump supports dumping multiple databases and/or tables #10094

Closed

Description

@aronchanisme

Is there an existing issue for the same feature request?

  • I have checked the existing issues.

Is your feature request related to a problem?

Currently there are some constraints of mo-dump tool,
1. mo-dump only supports exporting the backup of a single database, if you have several databases to backup, you need to manually run mo-dump for several times.
2. -tbl [table name]: Optional parameter. If the parameter is empty, the whole database will be exported. If you want to take the backup specific tables, then you can specify multiple -tbl and table names in the command.

Describe the feature you'd like

mo-dump supports dumping multiple databases and/or tables if it's specified by a user.

Describe implementation you've considered

  1. For databases:
  • Support multiple databases by specifying them in a list, sperated by ,
  • Support all databases by sepecifiying them using all. However, it should be discussed first whether internal databases should also be exported, or only user databases should be exported. @domingozhang @jianwan0214
mo-dump -u dump -p xxx -h 127.0.0.1 -P 6001 -db db1,db2,db3 > /tm/db1-db2-db3.sql
mo-dump -u dump -p xxx -h 127.0.0.1 -P 6001 -db all > /tm/all-dbs.sql
  1. For tables:
    Support multiple tables when dumping one specific database by specifiying them in only one -tbl option, instead of multiple
mo-dump -u dump -p xxx -h 127.0.0.1 -P 6001 -db db1 -tbl tbl1,tbl2,tbl3 > /tm/all-dbs.sql

but not like this, because it will be very annoying to write so many -tbl options when dumping multiple tables,

mo-dump -u dump -p xxx -h 127.0.0.1 -P 6001 -db db1 -tbl tbl1 -tbl tbl2 -tbl tbl3 > /tm/all-dbs.sql

Documentation, Adoption, Use Case, Migration Strategy

https://docs.matrixorigin.cn/en/0.7.0/MatrixOne/Develop/export-data/modump/#syntax

Additional information

企业微信截图_35a4bad5-0bce-4524-9e99-cba21ddf193c

Activity

  1. added this to the V0.8.0-Backlog milestone on Jun 16, 2023
  2. added
    priority/p1
    on Jul 3, 2023
  3. added
    attention/doc-influence
    on Jul 5, 2023
  4. modified the milestones: 1.0.0, 1.1.0 on Aug 19, 2023
  5. added
    source/on-demand
    and removed
    source/dev
    on Aug 28, 2023
  6. aronchanisme commented on Oct 30, 2023

    @aronchanisme
    ContributorAuthor

    Test date: 2023/10/30
    Commit id:

    root@test0:/data/mo/20231030_1050/matrixone# mo_ctl get_cid 
    2023-10-30 16:13:26.890 UTC+0800    [INFO]    Try get mo commit id
    commit 0175397c3d933aff66b3fa950f85d92fc05cab2c
    Author: LiuBo <[email protected]>
    Date:   Mon Oct 30 10:22:47 2023 +0800
    
        [bug] util: fix a user case in address manager. (#12273)
        
    2023-10-30 16:13:26.939 UTC+0800    [INFO]    Get commit id succeeded

    For modump with multiple tables,

    Senario 1. Dump multiple tables with no data, already tested as stated here #10091 (comment)

    Senario 2. Dump multiple tables with data,

    1 Test case 1

    mo_ctl connect
    create database dump_tables_test;
    use dump_tables_test;
    create table t1(id int)
    insert into t1 values (1),(2),(3);
    select * from t1;
    create table t2(name varchar(25));
    insert into t2 values ('A'),('B'),('C');
    select * from t2;
    exit
    ./mo-dump -h 127.0.0.1 -u dump -p 111 -P 6001 -db dump_tables_test -tbl t1,t2  > /data/mo_backup/20231030_1605/test_1.sql
    cat /data/mo_backup/20231030_1605/test_1.sql
    mo_ctl sql 'drop database if exists dump_tables_test;'
    mo_ctl sql "show databases like '%dump_tables_test%';"
    sed -i '1iuse dump_tables_test;' /data/mo_backup/20231030_1605/test_1.sql
    sed -i '1icreate database if not exists dump_tables_test;' /data/mo_backup/20231030_1605/test_1.sql
    cat /data/mo_backup/20231030_1605/test_1.sql
    mo_ctl sql /data/mo_backup/20231030_1605/test_1.sql
    mo_ctl sql "show databases like '%dump_tables_test%';show tables in dump_tables_test;select * from dump_tables_test.t1; select * from dump_tables_test.t2;"
    
    image image image image

    2 Test case 2: table nation and region in database tpch_10g

    ./mo-dump -h 127.0.0.1 -u dump -p 111 -P 6001 -db tpch_10g -tbl nation,region  > /data/mo_backup/20231030_1605/test_2.sql
    cat /data/mo_backup/20231030_1605/test_2.sql
    image image
  7. aronchanisme commented on Nov 22, 2023

    @aronchanisme
    ContributorAuthor

    Dump multiple databases with and without data, failed on both scenarios, since only one database is dumped when two are specified.

    ./mo-dump -h 127.0.0.1 -P 6001 -p 111 -u dump -db tpch_1g,ssb_1g > xxx.sql
    ./mo-dump -h 127.0.0.1 -P 6001 -p 111 -u dump -db tpch_1g,ssb_1g --no-data  > xxx.sql

    commit id:

    root@test0:/data/mo_br_test/mo_dump/mo_dump# mo_ctl get_cid
    2023-11-22 15:38:14.898 UTC+0800    [INFO]    Try get mo commit id
    commit 19e9f498d322034a0d29fab2a39daedfb8a9ba5c
    Author: triump2020 <[email protected]>
    Date:   Mon Nov 20 15:29:14 2023 +0800
    
        Reuse object stats (#12828)
        
    2023-11-22 15:38:14.961 UTC+0800    [INFO]    Get commit id succeeded

    企业微信截图_1700638275172
    企业微信截图_1700638284501
    企业微信截图_17006385693948

  8. aronchanisme commented on Nov 22, 2023

    @aronchanisme
    ContributorAuthor

    Create 2 empty databases and try dumping them, this is ok though. Something must be wrong. Please kindly help take a look. Thanks. @YANGGMM
    企业微信截图_17006390724549

  9. xmh1011 commented on Nov 22, 2023

    @xmh1011
    Contributor

    Create 2 empty databases and try dumping them, this is ok though. Something must be wrong. Please kindly help take a look. Thanks. @YANGGMM 企业微信截图_17006390724549

    fixed by: matrixorigin/mo_dump#3

  10. aronchanisme commented on Nov 22, 2023

    @aronchanisme
    ContributorAuthor

    With data, ok
    企业微信截图_17006455667283
    企业微信截图_17006456566348

    With no data, ok
    企业微信截图_17006434421166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

attention/doc-influencekind/featurepriority/p1source/on-demand

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions