Skip to main content

Back Up and Restore Databend Schema Data

This guideline will introduce how to back up and restore the schema data which in meta service with mydumper tool.

Before You Begin

caution

mydumper only export the Databend schema(including database and table) which stored in Databend meta service, PLEASE DON'T USE IT TO EXPORT DATA!

If you don't have a Databend user for dumping, please create one:

mysql -h127.0.0.1 -uroot -P3307
CREATE USER user1 IDENTIFIED BY 'abc123';
GRANT ALL on *.* TO user1;

Export Schema from Databend

mydumper --host 127.0.0.1 --user user1 --password abc123 --port 3307 \
--no-locks \
--no-data \
--database test_db \
--outputdir /tmp/test_db
tip

--host: Do not dump or import table data.

--no-locks: Do not execute the temporary shared read lock.

--no-data: Do not dump or import table data.

--database: Database to dump.

--outputdir: Directory to output files to.

The /tmp/test_db directory seems look:

tree /tmp/test_db/ 
├── metadata
├── test_db-schema-create.sql
└── test_db.t1-schema.sql

Restore Schema into Databend

To restore schema into a new Databend, use myloader to import the /tmp/test_db directory.

myloader --host 127.0.0.1 --user user1 --password abc123 --port 3307 \
--directory /tmp/test_db/
tip

--directory: Directory of the dump to import.