Logical backup and restore, generated from the schema.
A backup is a directory with two files:
schema.tql— the database's schema as TypeDB describes it, the host's types and functions included;data.jsonl— one instance a line, every entity and relation of every type in the database.
Instances carry no database ids. An instance's id is a hash of its type,
its attributes, and the ids of the instances it links, so the same content
gives the same file: back up, restore into an empty database, back up again,
and the two data.jsonl files are byte-identical. Lines are sorted, entities
before relations, and a relation comes after every relation it links.
A line:
{"has":[["content","string","…"]],"id":"…","links":[["claim","…"]],"type":"sourcing"}Attributes nothing owns are not instances of anything a backup records, and TypeDB discards them anyway.
Leaving attributes out. backup/3 with omit: [label] writes a backup
without those attribute types: their declarations and every owns of them
are taken out of schema.tql, and their values out of data.jsonl. It is
for what a host derives and can rebuild, such as an embedding: a vector
attribute needs a TypeDB build with vectors to be defined at all, so a
backup that kept it could be restored only onto such a build. An omitted
attribute must not be @card(1..) on any owner, or the restore would
refuse its own data; and nothing else in the schema, a function included,
may name it. Either is {:error, {:cannot_omit, label}}, and nothing is
written. The library's own types cannot be omitted.