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 (or just update the server configuration for data directory path).
TypeDB will prevent you from moving data across incompatible database encoding versions.
|Database encoding Version||Compatible TypeDB Versions|
|0||2.0.0 - 2.5.0|
|1||2.6.0 - 2.7.1|
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.
Migration or backup using the export/import features is a two-step process: schema migration, followed by data migration.
Note that this binary file is often two times larger than the original database. Please ensure your disk has sufficient free capacity to store a file of this size. If your have to migrate data that will not fit onto disk, please reach out to us on our Discord community or Forum where we can advise you further.
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 if the TypeQL language definitions have changed 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] --port=[server rpc port] --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.
After the import completes, you can import the exported binary data into the prepared database containing your schema:
typedb server import --database=[database] --port=[server rpc port] --file=[filename].typedb