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

  • Importer の既知のサポート制限事項を確実に理解するには、「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 "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 クエリを作成するには、独自のスクリプトを記述するか、Insomnia などの HTTP クライアントを使う必要があります。

認証方法など、GitHub GraphQL API での作業の始め方について詳しくは、「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 (classic) for the source organization. For requirements, see "GitHub Enterprise Importer のアクセスの管理."
targetAccessTokenYour personal access token (classic) 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. GitHub CLI をインストールします。 GitHub CLI のインストール手順については、GitHub CLI リポジトリを参照してください。

    注: GitHub CLI のバージョン 2.4.0 以降が必要です。 gh --version コマンドを使って、インストールされているバージョンを確認できます。

  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 (classic) that can access the source organization and destination enterprise, then set the personal access tokens (classic) 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 (classic) that meets all the requirements to authenticate for the destination enterprise for organization migrations.

  3. Set environment variables for the personal access tokens (classic), replacing TOKEN in the commands below with the personal access tokens (classic) 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

上のコマンドのプレースホルダーを次の値に置き換えます。

プレースホルダー
SOURCE移行元の Organization の名前
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.