Skip to main content

Migrating your repository with Enterprise Live Migrations

Migrate from GitHub Enterprise Server to GHE.com with minimal downtime.

Who can use this feature?

Site administrators on GitHub Enterprise Server who are also enterprise owners on GHE.com.

Note

Enterprise Live Migrations is in public preview and subject to change.

Tip

As you follow this guide, you can refer to the Enterprise Live Migrations CLI reference for more detailed usage information. If you encounter errors, see Troubleshooting live migrations from GitHub Enterprise Server to GHE.com.

Prerequisites

Make sure you're ready for your migration. See Preparing for your live migration from GitHub Enterprise Server to GHE.com.

1. Create access tokens

You must authenticate with a personal access token (classic) for both the source and destination of the migration. For detailed instructions, see Managing your personal access tokens.

Make a note of both tokens, as you will need them in the next step.

  1. Create a personal access token (classic) on GitHub Enterprise Server with the following scopes.

    • repo
    • admin:org
    • admin:repo_hook
    • admin:org_hook
  2. Create a personal access token (classic) on GHE.com with the following scopes.

    • repo
    • workflow
    • admin:org
    • admin:repo_hook
    • admin:enterprise
  3. If single sign-on is enforced on the target organization on GHE.com, authorize the GHE.com token.

2. Configure GitHub Enterprise Server

You must set some configuration on the GitHub Enterprise Server instance before performing a migration. These configuration values apply to all ELM migrations. Developers on GitHub Enterprise Server may experience a brief downtime when you apply the new configuration.

  1. Access the GitHub Enterprise Server administrative shell over SSH. See Accessing the administrative shell (SSH).

  2. Set the following configuration variables with ghe-config.

    For example: ghe-config app.elm-exporter.enabled true

    VariableSet this to...
    app.elm-exporter.enabledtrue
    app.elm.internal-webhooks-enabledtrue
    app.elm-exporter.webhooks-loopback-address-enabledtrue
    secrets.elm-exporter.migration-target-urlThe API URL for your destination enterprise (for example: https://api.octocorp.ghe.com). Do not include a trailing slash at the end of the URL.
    secrets.elm-exporter.migration-target-tokenThe access token you created for GHE.com.
    secrets.elm-exporter.source-tokenThe access token you created for GitHub Enterprise Server.
    secrets.elm-exporter.source-userThe username associated with the GitHub Enterprise Server token (for example: ghe-admin).
    app.migrations.enabledIf you don't already have migrations enabled on the instance, you must set this to true.
  3. Apply the configuration.

    Shell
    ghe-config-apply
    

3. Set required environment variables

When the configuration has been applied, and before starting a migration, set required environment variables. For example:

export API_URL='http://localhost:1738'

Important

Copy the values for API_URL and MIGRATION_MANAGER_HMAC_KEY verbatim. The other variables are specific to your environment.

VariableRequired value
API_URLhttp://localhost:1738
MIGRATION_MANAGER_HMAC_KEY$(ghe-config secrets.elm-exporter.elm-exporter-hmac-keys)
MIGRATION_TARGET_URLThe API URL for your destination enterprise (for example: https://api.octocorp.ghe.com). Do not include a trailing slash at the end of the URL.
MIGRATION_TARGET_TOKENThe personal access token (classic) for GHE.com

Any of these values can also be provided as CLI flags on any elm command, which will take priority over the variables. For example: --api-url http://localhost:1738.

4. Create a migration

Create a new migration by specifying the source and target repository details. --pat-name must be set to system-pat as a static value. The other values are placeholders specific to your environment.

Note

The target-org can be new or existing. If the target organization doesn't already exist, it will be created during the migration. However, no settings from the source organization will be migrated.

Shell
elm migration create \
  --source-org EXISTING-GHES-ORG \
  --source-repo EXISTING-GHES-REPO \
  --target-org GHEC-ORG \
  --target-repo NEW-GHEC-REPO \
  --target-api GHEC-API-URL \
  --pat-name system-pat

For example:

elm migration create \
  --source-org my-ghes-org \
  --source-repo my-ghes-repo \
  --target-org my-dr-org \
  --target-repo my-dr-repo \
  --target-api $MIGRATION_TARGET_URL \
  --pat-name system-pat

Optional flags:

  • --start: If you're ready to start the migration immediately.
  • --target-visibility: Migrated repositories are created with internal visibility by default, but you can specify private.

Save the migration ID

You should see a response like the following:

{
  "migrationId": "2b5c9eae-b5da-4306-ab04-2a29cc2b7cb9",
  "expiresAt":