Skip to main content
Мы публикуем частые обновления нашей документации, и перевод этой страницы может все еще выполняться. Актуальные сведения см. в документации на английском языке.

Migrating organizations from GitHub.com to GitHub Enterprise Cloud

You can migrate organizations from GitHub.com to GitHub Enterprise Cloud, using the GitHub CLI or the GraphQL API.

Примечание. GitHub Enterprise Importer в настоящее время находится в общедоступной бета-версии и может быть изменен.

About organization migrations with GitHub Enterprise Importer

Миграцию можно выполнить с помощью GitHub CLI или API.

GitHub CLI упрощает процесс миграции и рекомендуется для большинства клиентов. Опытные клиенты с большими потребностями в настройке могут использовать API для создания собственных интеграций с GitHub Enterprise Importer.

Чтобы просмотреть инструкции по использованию API, используйте переключатель инструментов в верхней части страницы.
Чтобы просмотреть инструкции по использованию GitHub CLI, используйте переключатель инструментов в верхней части страницы.

Prerequisites

  • Чтобы убедиться, что вы понимаете известные ограничения поддержки средства импорта, ознакомьтесь с разделом Сведения о GitHub Enterprise Importer.
  • Мы настоятельно рекомендуем выполнить пробную версию миграции и завершить миграцию в рабочей среде вскоре после этого. Дополнительные сведения о рекомендациях по запуску пробной версии см. в разделе Подготовка к выполнению миграции с помощью GitHub Enterprise Importer.
  • Хотя это не обязательно, рекомендуется остановить работу во время миграции рабочей среды. Importer не поддерживает разностные миграции, поэтому любые изменения, происходящие во время миграции, не будут перенесены. Если вы решили не останавливать работу во время миграции рабочей среды, необходимо вручную перенести эти изменения.
  • For the source organization, you must be an organization owner or have the migrator role. For more information, see "Granting the migrator role for GitHub Enterprise Importer."
  • For the destination enterprise account, you must be an enterprise owner.

Step 0: Get ready to use the GitHub GraphQL API

Чтобы создавать запросы GraphQL, необходимо написать собственные скрипты или использовать HTTP-клиент, например Insomnia.

Дополнительные сведения о начале работы с API GraphQL GitHub, в том числе о проверке подлинности, см. в разделе Формирование вызовов с помощью GraphQL.

Step 1: Get the enterprise ID for your migration destination

As an enterprise owner in GitHub.com, use the following query to return the ID for the enterprise account you want to own the migrated organization. You'll need the enterprise ID to identify your migration destination.

query(
  $slug: String!
){
  enterprise (slug: $slug)
  {
    slug
		id
  }
}

Query variableDescription
slugThe slug for your enterprise account, which you can identify by looking at the URL for your enterprise, https://github.com/enterprises/SLUG.

Step 2: Start your organization migration

When you start a migration, a single organization and its accompanying data migrates into a brand new organization within the destination enterprise that you identify.

mutation startOrganizationMigration (
  $sourceOrgUrl: URI!,
  $targetOrgName: String!,
  $targetEnterpriseId: ID!,
  $sourceAccessToken: String!,
	$targetAccessToken: String!
){
  startOrganizationMigration( input: {
    sourceOrgUrl: $sourceOrgUrl,
    targetOrgName: $targetOrgName,
    targetEnterpriseId: $targetEnterpriseId,
    sourceAccessToken: $sourceAccessToken,
		targetAccessToken: $targetAccessToken
  }) {
    orgMigration {
      id
    }
  }
}
Query variableDescription
sourceOrgUrlThe URL of the source organization, such as https://github.com/octo-org.
targetOrgNameThe name you want the new organization to have. Must be unique on GitHub.com.
targetEnterpriseIdThe ID of the enterprise that you want to create the new organization in, returned by step 2.
sourceAccessTokenYour personal access token for the source organization. For requirements, see "Управление доступом для GitHub Enterprise Importer."
targetAccessTokenYour personal access token for the destination enterprise.

In the next step, you'll use the migration ID returned from the startOrganizationMigration mutation to check the migration status.

Step 3: Check the status of your migration

To detect any migration failures and ensure your migration is working, you can query the OrganizationMigration(s) that you have created to see the migration status using the getMigration query.

The query will return with a status to let you know if the migration is queued, in progress, failed, or completed, plus information about how many repositories are waiting to be migrated. If your migration failed, the Importer will provide a reason for the failure.

query (
  $id: ID!
){
  node( id: $id ) {
    ... on OrganizationMigration {
      id
			sourceOrgUrl
			targetOrgName
      state
      failure_reason
      remaining_repositories_count
      total_repositories_count
    }
  }
}
Query variableDescription
idThe id of your migration.

Step 1: Install the GEI extension of the GitHub CLI

Если это ваша первая миграция, необходимо установить GEI extension of the GitHub CLI. Дополнительные сведения о GitHub CLI см. в разделе Сведения о GitHub CLI.

  1. Install the GitHub CLI. Инструкции по установке для GitHub CLI см. в репозитории GitHub CLI.

    Note: You need version 2.4.0 or newer of GitHub CLI. You can check the version you have installed with the gh --version command.

  2. Установите GEI extension.

    Shell
    gh extension install github/gh-gei

Каждый раз, когда вам нужна помощь с GEI extension, вы можете использовать --help флаг с командой. Например, gh gei --help отобразит список всех доступных команд и gh gei migrate-repo --help все параметры, доступные migrate-repo для этой команды.

Step 2: Update the GEI extension of the GitHub CLI

GEI extension обновляется еженедельно. Чтобы убедиться, что вы используете последнюю версию, обновите расширение.

gh extension upgrade github/gh-gei

Step 3: Set environment variables

Before you can use the GEI extension to migrate to GitHub Enterprise Cloud, you must create personal access tokens that can access the source organization and destination enterprise, then set the personal access tokens as environment variables.

  1. Create and record a personal access token that meets all the requirements to authenticate for the source organization for organization migrations. For more information, see "Управление доступом для GitHub Enterprise Importer."

  2. Create and record a personal access token that meets all the requirements to authenticate for the destination enterprise for organization migrations.

  3. Set environment variables for the personal access tokens, replacing TOKEN in the commands below with the personal access tokens you recorded above. Use GH_PAT for the destination enterprise and GH_SOURCE_PAT for the source organization.

    • If you're using Terminal, use the export command.

      Shell
      export GH_PAT="TOKEN"
      export GH_SOURCE_PAT="TOKEN"
    • If you're using PowerShell, use the $env command.

      Shell
      $env:GH_PAT="TOKEN"
      $env:GH_SOURCE_PAT="TOKEN"

Step 4: Migrate your organization

To migrate an organization, use the gh gei migrate-org command.

Shell
gh gei migrate-org --github-source-org SOURCE --github-target-org DESTINATION --github-target-enterprise ENTERPRISE

Замените заполнители в приведенной выше команде следующими значениями.

ЗаполнительЗначение
ИСТОЧНИКИмя исходной организации
DESTINATIONThe name you want the new organization to have. Must be unique on GitHub.com.
ENTERPRISEThe slug for your destination enterprise, which you can identify by looking at the URL for your enterprise account, https://github.com/enterprises/SLUG.

Step 5: Validate your migration and check the error log

After your migration has finished, we recommend that you check the migration log repository. For more information, see "Доступ к журналам миграции для GitHub Enterprise Importer."

Finally, we recommend you perform a soundness check of your organization and migrated repositories.