{{< details >}}

  • Tier: 专业版, 旗舰版
  • Offering: 私有化部署

{{< /details >}}

极狐GitLab 群组 Wiki 仓库可以在存储之间移动。此 API 可以帮助您,例如,迁移到 Gitaly 集群 或迁移一个群组 Wiki。此 API 不管理群组中的项目仓库。要安排项目移动,请使用项目仓库存储移动 API

随着极狐GitLab 处理群组仓库存储移动,它会经历不同的状态。state 的值为:

  • initial:记录已创建,但后台作业尚未安排。
  • scheduled:后台作业已安排。
  • started:群组仓库正在复制到目标存储。
  • replicated:群组已被移动。
  • failed:群组仓库复制失败,或校验和不匹配。
  • finished:群组已被移动,源存储上的仓库已被删除。
  • cleanup failed:群组已被移动,但源存储上的仓库无法删除。

为了确保数据完整性,极狐GitLab 在移动期间将群组置于临时只读状态。在此期间,如果用户尝试推送新的提交,他们将收到此消息:

The repository is temporarily read-only. Please try again later.

此 API 需要您以管理员身份进行身份验证

API 还可用于移动其他类型的仓库:

检索所有群组仓库存储移动

GET /group_repository_storage_moves

默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的

示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/group_repository_storage_moves"

示例响应:

[
  {
    "id": 1,
    "created_at": "2020-05-07T04:27:17.234Z",
    "state": "scheduled",
    "source_storage_name": "default",
    "destination_storage_name": "storage2",
    "group": {
      "id": 283,
      "web_url": "https://gitlab.example.com/groups/testgroup",
      "name": "testgroup"
    }
  }
]

检索单个群组的所有仓库存储移动

要检索单个群组的所有仓库存储移动,您可以使用以下端点:

GET /groups/:group_id/repository_storage_moves

默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的

支持的属性:

属性 类型 必需 描述
group_id integer yes 群组的 ID。

示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/1/repository_storage_moves"

示例响应:

[
  {
    "id": 1,
    "created_at": "2020-05-07T04:27:17.234Z",
    "state": "scheduled",
    "source_storage_name": "default",
    "destination_storage_name": "storage2",
    "group": {
      "id": 283,
      "web_url": "https://gitlab.example.com/groups/testgroup",
      "name": "testgroup"
    }
  }
]

获取单个群组仓库存储移动

要在所有现有仓库存储移动中检索单个仓库存储移动,可以使用以下端点:

GET /group_repository_storage_moves/:repository_storage_id

支持的属性:

属性 类型 必需 描述
repository_storage_id integer yes 群组仓库存储移动的 ID。

示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/group_repository_storage_moves/1"

示例响应:

{
  "id": 1,
  "created_at": "2020-05-07T04:27:17.234Z",
  "state": "scheduled",
  "source_storage_name": "default",
  "destination_storage_name": "storage2",
  "group": {
    "id": 283,
    "web_url": "https://gitlab.example.com/groups/testgroup",
    "name": "testgroup"
  }
}

获取群组的单个仓库存储移动

给定一个群组,您可以通过以下端点检索该群组的特定仓库存储移动:

GET /groups/:group_id/repository_storage_moves/:repository_storage_id

支持的属性:

属性 类型 必需 描述
group_id integer yes 群组的 ID。
repository_storage_id integer yes 群组仓库存储移动的 ID。

示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/1/repository_storage_moves/1"

示例响应:

{
  "id": 1,
  "created_at": "2020-05-07T04:27:17.234Z",
  "state": "scheduled",
  "source_storage_name": "default",
  "destination_storage_name": "storage2",
  "group": {
    "id": 283,
    "web_url": "https://gitlab.example.com/groups/testgroup",
    "name": "testgroup"
  }
}

为群组安排仓库存储移动

为群组安排仓库存储移动。此端点:

  • 仅移动群组 Wiki 仓库。
  • 不移动群组中的项目仓库。要安排项目移动,请使用项目仓库存储移动 API。
POST /groups/:group_id/repository_storage_moves

支持的属性:

属性 类型 必需 描述
group_id integer yes 群组的 ID。
destination_storage_name string no 目标存储分片的名称。如果未提供,则根据存储权重选择存储。

示例请求:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     --header "Content-Type: application/json" \
     --data '{"destination_storage_name":"storage2"}' \
     --url "https://gitlab.example.com/api/v4/groups/1/repository_storage_moves"

示例响应:

{
  "id": 1,
  "created_at": "2020-05-07T04:27:17.234Z",
  "state": "scheduled",
  "source_storage_name": "default",
  "destination_storage_name": "storage2",
  "group": {
    "id": 283,
    "web_url": "https://gitlab.example.com/groups/testgroup",
    "name": "testgroup"
  }
}

为存储分片上的所有群组安排仓库存储移动

为存储在源存储分片上的每个群组仓库安排仓库存储移动。此端点一次迁移所有群组。有关更多信息,请参阅移动所有群组

POST /group_repository_storage_moves

支持的属性:

属性 类型 必需 描述
source_storage_name string yes 源存储分片的名称。
destination_storage_name string no 目标存储分片的名称。如果未提供,则根据存储权重选择存储。

示例请求:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     --header "Content-Type: application/json" \
     --data '{"source_storage_name":"default"}' \
     --url "https://gitlab.example.com/api/v4/group_repository_storage_moves"

示例响应:

{
  "message": "202 Accepted"
}