Help us learn about your current experience with the documentation. Take the survey.

组仓库存储移动 API

  • 版本:Premium, Ultimate
  • 产品:GitLab Self-Managed, GitLab Dedicated

组 Wiki 仓库可以在不同存储之间移动。例如,此 API 可以帮助您迁移到 Gitaly Cluster (Praefect)或迁移组 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 组的 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 组仓库存储移动的 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 组的 ID。
repository_storage_id integer 组仓库存储移动的 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 组的 ID。
destination_storage_name string 目标存储分片的名称。如果未提供,将基于存储权重选择存储。

示例请求:

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 源存储分片的名称。
destination_storage_name string 目标存储分片的名称。如果未提供,将基于存储权重选择存储。

示例请求:

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"
}