如何 backup/dump arangoDB 中的图形结构

How to backup/dump structure of graphs in arangoDB

有没有办法转储arangoDB数据库的图结构,因为 不幸的是,arangodump 只是转储边缘和集合的数据。

目前ArangoDB通过系统集合_graphs中的文档来管理图。 一份文件等于一张图表。它包含配置边集合方向的graph name, involved vertex collections and Edge Definition

根据文档,为了转储所有集合(包括系统集合)的结构信息,您 运行 以下

arangodump --dump-data false --include-system-collections true --output-directory "dump"

如果您不想包含系统集合,则不要提供参数(默认为 false)或提供 false 值。

集合的结构和数据是如何转储的,见下文documentation

Structural information for a collection will be saved in files with name pattern .structure.json. Each structure file will contains a JSON object with these attributes:

parameters: contains the collection properties

indexes: contains the collection indexes

Document data for a collection will be saved in files with name pattern .data.json. Each line in a data file is a document insertion/update or deletion marker, alongside with some meta data.

为了测试,我经常想提取一个已知结构的子图。我用它来测试我的查询。该方法不是很漂亮,但它可能会解决您的问题。我写了关于它的博客 here

虽然@Raf的回答被接受了,--dump-data false只会给出所有集合的结构文件,但不会有数据。包括 --include-system-collections true 会给出 _graphs 系统集合的结构,该结构不会包含与单个图 creation/structure.

相关的信息

For Graph creation data as well

正确命令如下

arangodump --server.database <DB_NAME> --include-system-collections true --output-directory <YOUR_DIRECTORY>

我们会对具有以下数据格式的 _graphs_<long_id>.data.json 命名文件感兴趣。

{
    "type": 2300,
    "data":
    {
        "_id": "_graphs/social",
        "_key": "social",
        "_rev": "_WaJxhIO--_",
        "edgeDefinitions": [
            {
                "collection": "relation",
                "from": ["female", "male"],
                "to": ["female", "male"]
            }
        ],
        "numberOfShards": 1,
        "orphanCollections": [],
        "replicationFactor": 1
    }
}

希望这对正在寻找我的需求的其他用户有所帮助!