{"meta":{"title":"Exporting migration data from GitHub.com","intro":"You can export migration data from an organization on GitHub.com by using the API to select repositories to migrate, then generating a migration archive that you can import into a GitHub Enterprise Server instance.","product":"Migrations","breadcrumbs":[{"href":"/en/enterprise-server@3.21/migrations","title":"Migrations"},{"href":"/en/enterprise-server@3.21/migrations/using-ghe-migrator","title":"ghe-migrator"},{"href":"/en/enterprise-server@3.21/migrations/using-ghe-migrator/exporting-migration-data-from-githubcom","title":"Export from GitHub.com"}],"documentType":"article"},"body":"# Exporting migration data from GitHub.com\n\nYou can export migration data from an organization on GitHub.com by using the API to select repositories to migrate, then generating a migration archive that you can import into a GitHub Enterprise Server instance.\n\n## Preparing the source organization on GitHub\n\n1. Ensure that you have [owner permissions](/en/enterprise-server@3.21/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization) on the source organization's repositories.\n\n2. [Generate an access token](/en/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with the `repo` and `admin:org` scopes on GitHub.com.\n\n3. To minimize downtime, make a list of repositories you want to export from the source instance. You can add multiple repositories to an export at once using a text file that lists the URL of each repository on a separate line.\n\n## Exporting the organization's repositories\n\n> \\[!NOTE]\n> Fork relationships do not persist after a migration.\n\nTo export repository data from GitHub.com, use [the Migrations API](/en/rest/migrations).\n\nThe Migrations API is currently in a preview period, which means that the endpoints and parameters may change in the future.\n\n## Generating a migration archive\n\n> \\[!NOTE]\n> Locking a repository prevents all write access to the repository. You cannot associate new teams or collaborators with a locked repository.\n>\n> If you're performing a trial run, you do not need to lock the repository. When you migrate data from a repository that's in use, GitHub strongly recommends locking the repository. For more information, see [About ghe-migrator](/en/enterprise-server@3.21/migrations/using-ghe-migrator/about-ghe-migrator#types-of-migrations).\n\n1. Notify members of your organization that you'll be performing a migration. The export can take several minutes, depending on the number of repositories being exported. The full migration including import may take several hours so we recommend doing a trial run in order to determine how long the full process will take. For more information, see [About ghe-migrator](/en/enterprise-server@3.21/migrations/using-ghe-migrator/about-ghe-migrator#types-of-migrations).\n\n2. Start a migration by sending a `POST` request to [the migration endpoint](/en/rest/migrations#start-an-organization-migration). You'll need:\n\n   * Your access token for authentication.\n\n   * A [list of the repositories](/en/rest/repos#list-organization-repositories) you want to migrate:\n\n     ```shell\n     curl -H \"Authorization: Bearer GITHUB_ACCESS_TOKEN\" \\\n     -X POST \\\n     -H \"Accept: application/vnd.github+json\" \\\n     -d'{\"lock_repositories\":true,\"repositories\":[\"ORG_NAME/REPO_NAME\", \"ORG_NAME/REPO_NAME\"]}' \\\n     https://api.github.com/orgs/ORG_NAME/migrations\n     ```\n\n   * If you want to lock the repositories before migrating them, make sure `lock_repositories` is set to `true`. This is highly recommended.\n\n   * You can exclude file attachments by passing `exclude_attachments: true` to the endpoint. File attachments can be large and may needlessly bloat your final migration archive. The final archive size must be less than 20 GB.\n\n   This request returns a unique `id` which represents your migration. You'll need it for subsequent calls to the Migrations API.\n\n3. Send a `GET` request to [the migration status endpoint](/en/rest/migrations#get-an-organization-migration-status) to fetch the status of a migration. You'll need:\n\n   * Your access token for authentication.\n   * The unique `id` of the migration:\n\n     ```shell\n     curl -H \"Authorization: Bearer GITHUB_ACCESS_TOKEN\" \\\n     -H \"Accept: application/vnd.github+json\" \\\n     https://api.github.com/orgs/ORG_NAME/migrations/ID\n     ```\n\n   A migration can be in one of the following states:\n\n   * `pending`, which means the migration hasn't started yet.\n   * `exporting`, which means the migration is in progress.\n   * `exported`, which means the migration finished successfully.\n   * `failed`, which means the migration failed.\n\n4. After your migration has exported, download the migration archive by sending a `GET` request to [the migration download endpoint](/en/rest/migrations#download-an-organization-migration-archive). You'll need:\n   * Your access token for authentication.\n   * The unique `id` of the migration:\n\n     ```shell\n     curl -H \"Authorization: Bearer GITHUB_ACCESS_TOKEN\" \\\n     -H \"Accept: application/vnd.github+json\" \\\n     -L -o migration_archive.tar.gz \\\n     https://api.github.com/orgs/ORG_NAME/migrations/ID/archive\n     ```\n\n5. The migration archive is automatically deleted after seven days. If you would prefer to delete it sooner, you can send a `DELETE` request to [the migration archive delete endpoint](/en/rest/migrations#delete-an-organization-migration-archive). You'll need:\n   * Your access token for authentication.\n   * The unique `id` of the migration:\n\n     ```shell\n     curl -H \"Authorization: Bearer GITHUB_ACCESS_TOKEN\" \\\n     -X DELETE \\\n     -H \"Accept: application/vnd.github+json\" \\\n     https://api.github.com/orgs/ORG_NAME/migrations/ID/archive\n     ```\n\n6. To prepare the archived migration data for import into a GitHub Enterprise Server instance, see [Migrating data to GitHub Enterprise Server](/en/enterprise-server@3.21/migrations/using-ghe-migrator/migrating-data-to-github-enterprise-server#preparing-the-migrated-data)."}