Export and import
In this guide, you’ll see how to export and import the schema and data of a TypeDB database.
This feature is introduced in TypeDB 3.4.0. If you want to export or import a database from earlier versions of TypeDB 3.x, simply update your server and client and follow this manual. You can import your databases exported from TypeDB 2.x following this guide. |
Understanding export and import
TypeDB database can be represented as two files:
-
A text file with its TypeQL schema description: a complete
define
query for the whole schema. -
A binary file with its data.
An exported database can be imported into another version of TypeDB using these two files. This is the best tool you can use to migrate a database between two incompatible versions of TypeDB (e.g., a migration from TypeDB 2.x to TypeDB 3.x).
Both operations are performed through the network, but the server and the client can be used on the same host.
Examples below use TypeDB Console as the most accessible client for these operations. Please check the Drivers API references to explore available programmatic commands (e.g., Rust).
Export
Database export allows a client to download database schema and data files from a TypeDB server for future import to the same or higher TypeDB version.
The files are created on the client side. The exported binary file might be up to two times larger than the original database. If the client connects to a remote host, the server’s disk remains unchanged, thus introducing zero risks to the stability of the server. Please ensure the client’s disk has enough free capacity to store a file of this size.
While the database data is being exported, parallel queries are allowed, but none of them will affect the exported data thanks to TypeDB’s transactionality. However, the database will not be available for such operations as deletion.
The files can be incomplete and corrupted if the export operation is interrupted by user. |
Perform through TypeDB Console
-
Make sure that your TypeDB Server is running.
-
Follow this guide for TypeDB Console set up and connection.
-
Execute
database export database-name schema.typeql data.typedb
, where-
database-name
is the name of the exported database; -
schema.typeql
is the exported schema definition file path; -
data.typedb
is the exported data file path.
-
-
The result (either
Successfully exported database
or an error) will be printed to the Console.
Import
Database import allows a client to upload previously exported database schema and data files to a TypeDB server.
For your safety, the imported database should not exist on the target server. It is possible to assign any new name to the imported database.
The database will be incomplete (and thus not recommended for usage) if the import operation is interrupted. It is expected to be automatically removed from the disk, but a small number of unexpected technical issues can prevent this from happening. A server restart will resolve any related issues. |
Perform through TypeDB Console
-
Make sure that your TypeDB Server is running.
-
Follow this guide for TypeDB Console set up and connection.
-
Execute
database import database-name schema.typeql data.typedb
, where-
database-name
is the new name of the imported database; -
schema.typeql
is the imported schema definition file path; -
data.typedb
is the imported data file path.
-
-
The result (either
Successfully imported database
or an error) will be printed to the Console.
Troubleshooting
Follow this checklist if any errors occur:
-
Ensure that you use compatible TypeDB Server and TypeDB Console.
-
Ensure that the correct file paths were specified for the operations.
-
Ensure that the schema has been imported correctly to the new database. Use TypeDB Studio or TypeDB Console to check the schema after import.
-
If you import a TypeDB 2.x database, some errors may be expected. Check out this page for a detailed guide.
If any errors persist, please join one of our communities and ask for assistance.