Migration and Backup
Migration or Backup by Copying
One method to migrate data across TypeDB distributions is by copying the data directory between servers. To do this,
simply shut down the servers, and copy the database you wish to migrate from the
server/data/ directory into the
server/data/ directory in the destination distribution.
TypeDB will warn you when moving data across incompatible database encoding versions.
|Database encoding Version||Compatible TypeDB Versions|
|0||2.0.0 - 2.5.0|
Migration or Backup using Export/Import
TypeDB offers a way to export all data into a binary format, and then re-import it elsewhere. Using the export feature is the best way to migrate to a version of TypeDB that is not backward compatible.
Note that this process will require local disk at least twice that of the database. If your have to migrate data that will not fit onto disk, please reach out to us on our Discord community or Forums where we can advise you further.
Migration or backup using the export/import features is a two-step process: schema migration followed by data migration.
The first step of migration is to migrate your schema. The command
database schema my-database-name in Console allows
you to get the current schema of a database as a single
define query. This schema query can then be loaded via the
Console to the new server.
Export the old schema using console (the old server must be running for this):
old/typedb console > database schema [database]
Copy the schema into a file named
You can skip the step of exporting schema if you already have a copy of your schema to import.
You may need to update your schema syntax when moving between TypeDB versions.
We then load the schema into the new TypeDB distribution:
new/typedb console > database create <database> > transaction <database> schema write [database]::schema::write> source <path to schema.tql> [database]::schema::write> commit
To create a binary export of a data from a TypeDB database, make sure that the TypeDB server you wish to export from is
running. After the server is running, use the following command that ships with
typedb server export --database=[database] --file=[filename].typedb
Note that this will NOT export the schema, only data. This file contains a complete copy of the data of the source database.
If you have already migrated the schema into a new server distribution, you can import the exported binary data:
typedb server import --database=[database] --file=[filename].typedb