OBDUMPER V4.3.5 and later versions support exporting database objects to multiple databases or schemas in a single export task, while maintaining the original single-database export behavior.
Implementation
Single-database mode
If the object parameters such as --table and --view do not contain specific databases or schemas (i.e., no periods are present), it is considered a single-database export. The default database specified by -D is used.
Multi-database mode
If any object parameter value contains specific databases or schemas (i.e., periods are present), it enters multi-database export mode. For example, test.table1, test1.*, *.*, test[0-9].tbl, test*.table, or test?.tbl.
In multi-database mode, a single multi-database export command is split into multiple single-database export subtasks. The details are as follows:
The object parameters such as
--tableand--vieware parsed, and<schema.object>is distributed to corresponding database/schema subtasks, specifying the export scope.If an object does not contain specific databases or schemas (e.g.,
--table 'db1.tbl1, tbl2' -D 'db2'), the default database specified by-Dis used, while other options remain unchanged.
In multi-database mode, exporting objects to different databases/schemas can be understood as executing multiple single-database export tasks. Here is an example:
obdumper -D test --table 'test1.tbl1,test2.tbl2' ...
-> obdumper -D test1 --table tbl1 ...
-> obdumper -D test2 --table tbl2 ...
obdumper -D test --table 'tbl1,test2.tbl2' ...
-> obdumper -D test --table tbl1 ...
-> obdumper -D test2 --table tbl2 ...
The default export directory structure includes an additional directory level for databases or schemas. The following example shows definition files for tables and views, along with table data files:
./outputs/
└── data
├── test
│ ├── TABLE
│ │ ├── sample_tbl1.csv
│ │ ├── sample_tbl1-schema.sql
│ │ ├── sample_tbl2.csv
│ │ └── sample_tbl2-schema.sql
│ └── VIEW
│ ├── sample_tbl1_view-schema.sql
│ └── sample_tbl2_view-schema.sql
└── test1
├── TABLE
│ ├── sample_tbl1.csv
│ ├── sample_tbl1-schema.sql
│ ├── sample_tbl2.csv
│ └── sample_tbl2-schema.sql
└── VIEW
├── sample_tbl1_view-schema.sql
└── sample_tbl2_view-schema.sql
7 directories, 12 files
Notice
If the database or schema name contains [, {, or other wildcard control characters, you need to escape these characters to successfully export.
Database-level DDL files
In OBDUMPER V5.0.0, exporting with --ddl --all without --no-nested-dir generates data/<database_name>/<database_name>-schema.sql under the directory specified by -f. For a multi-database export, a separate file is generated for each selected database or schema. In Oracle mode, SYS access is also required. If you specify --no-sys or --public-cloud, user definitions for the schema are skipped.
For example, an export with -f /dump -D db1 --ddl --all generates the following database-level DDL file (other files are omitted):
/dump/
└── data
└── db1
└── db1-schema.sql
The file contents depend on the compatibility mode:
Compatibility mode |
File contents |
|---|---|
| MySQL | A statement to create the database, including its name, default character set, and collation. |
| Oracle | A statement to create the user for the schema, along with the retrieved password hash and privilege grant statements. |
Definitions of objects such as tables and views are stored separately in their respective object directories. OBLOADER reads these SQL files to create databases or schemas and restore objects. The database-level DDL files are used in full database restore workflows with --create-database / --create-schema or --remap-database / --remap-schema.
OBDUMPER V5.0.0 no longer generates database.json. Databases or schemas and their objects are restored from these SQL files instead; the SQL files are not renamed copies of the old JSON file. The .MANIFEST.bin file generated during CSV export allows OBLOADER to reuse format settings such as delimiters, line separators, null values, and headers. It is neither a database-level DDL file nor a replacement for database.json.
For more information about database-level DDL export commands and restrictions, see Command-line options.
Examples
Scenario 1: Single-database export (unchanged)
Export the test database to /outputs.
./obdumper -h xxx.xxx.xxx.xxx -P 2883 -u test@mysql#cluster_a -p ****** -D test --csv --table '*' -f /outputs
Scenario 2: Multi-database export (export multiple databases in one task)
Method 1
./obdumper -h xxx.xxx.xxx.xxx -P 2883 -u test@mysql#cluster_a -p ****** --csv --table 'test[1-3].*' -f /outputsMethod 2
./obdumper -h xxx.xxx.xxx.xxx -P 2883 -u test@mysql#cluster_a -p ****** --csv --table 'test1.*, test2.*, test3.*' -f /outputsMethod 3
./obdumper -h xxx.xxx.xxx.xxx -P 2883 -u test@mysql#cluster_a -p ****** --csv --table 'test1.*' --table 'test2.*' --table 'test3.*' -f /outputs
Scenario 3: Tenant-level export (indirectly achieving full-tenant export)
Export all objects from all databases, including definitions and data.
./obdumper -h xxx.xxx.xxx.xxx -P 2883 -u test@mysql#cluster_a -p ****** --table '*.*' --ddl --csv --all -f /outputs