{"meta":{"title":"Exporting migration data from GitHub Enterprise Server","intro":"To change platforms or move from a trial instance to a production instance, you can export migration data from a GitHub Enterprise Server instance by preparing the instance, locking the repositories, and generating a migration archive.","product":"Migrations","breadcrumbs":[{"href":"/en/migrations","title":"Migrations"},{"href":"/en/migrations/using-ghe-migrator","title":"ghe-migrator"},{"href":"/en/migrations/using-ghe-migrator/exporting-migration-data-from-github-enterprise-server","title":"Export from GHES"}],"documentType":"article"},"body":"# Exporting migration data from GitHub Enterprise Server\n\nTo change platforms or move from a trial instance to a production instance, you can export migration data from a GitHub Enterprise Server instance by preparing the instance, locking the repositories, and generating a migration archive.\n\n## Preparing the GitHub Enterprise Server source instance\n\n1. Verify that you are a site administrator on the GitHub Enterprise Server source. The best way to do this is to verify that you can [SSH into the instance](/en/enterprise-server@3.22/admin/administering-your-instance/administering-your-instance-from-the-command-line/accessing-the-administrative-shell-ssh).\n\n2. [Generate an access token](/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with the `repo` and `admin:org` scopes on the GitHub Enterprise Server source instance.\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 GitHub Enterprise Server source repositories\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/migrations/using-ghe-migrator/about-ghe-migrator#types-of-migrations).\n\n1. SSH into GitHub.com. If your instance comprises multiple nodes, for example if high availability or geo-replication are configured, SSH into the primary node. If you use a cluster, you can SSH into any node. Replace HOSTNAME with the hostname for your instance, or the hostname or IP address of a node. For more information, see [Accessing the administrative shell (SSH)](/en/enterprise-server@3.22/admin/administering-your-instance/administering-your-instance-from-the-command-line/accessing-the-administrative-shell-ssh).\n\n   ```shell copy\n   ssh -p 122 admin@HOSTNAME\n   ```\n\n2. To prepare a repository for export, use the `ghe-migrator add` command with the repository's URL:\n   * If you're locking the repository, append the command with `--lock`. If you're performing a trial run, `--lock` is not needed.\n\n     ```shell\n     ghe-migrator add https://HOSTNAME/USERNAME/REPO-NAME --lock\n     ```\n\n   * You can exclude file attachments by appending `--exclude_attachments` to the command. File attachments can be large and may needlessly bloat your final migration archive.\n\n   * To prepare multiple repositories at once for export, create a text file listing each repository URL on a separate line, and run the `ghe-migrator add` command with the `-i` flag and the path to your text file.\n\n     ```shell\n     ghe-migrator add -i PATH/TO/YOUR/REPOSITORY_URL.txt\n     ```\n\n3. When prompted, enter your GitHub Enterprise Server username:\n\n   ```shell\n   Enter username authorized for migration:  admin\n   ```\n\n4. When prompted for a personal access token, enter the access token you created in [Preparing the GitHub Enterprise Server source instance](#preparing-the-github-enterprise-server-source-instance):\n\n   ```shell\n   Enter personal access token:  **************\n   ```\n\n5. When `ghe-migrator add` has finished it will print the unique \"Migration GUID\" that it generated to identify this export as well as a list of the resources that were added to the export. You will use the Migration GUID that it generated in subsequent `ghe-migrator add` and `ghe-migrator export` steps to tell `ghe-migrator` to continue operating on the same export.\n\n   ```shell\n   > 101 models added to export\n   > Migration GUID: EXAMPLE-MIGRATION-GUID\n   > Number of records in this migration:\n   > users                        |  5\n   > organizations                |  1\n   > repositories                 |  1\n   > teams                        |  3\n   > protected_branches           |  1\n   > pull_request_reviews         |  1\n   > milestones                   |  1\n   > issues                       |  3\n   > pull_requests                |  5\n   > pull_request_review_comments |  4\n   > commit_comments              |  2\n   > issue_comments               | 10\n   > issue_events                 | 63\n   > releases                     |  3\n   > attachments                  |  4\n   > projects                     |  2\n   ```\n\n   Each time you add a new repository with an existing Migration GUID it will update the existing export. If you run `ghe-migrator add` again without a Migration GUID it will start a new export and generate a new Migration GUID. **Do not re-use the Migration GUID generated during an export when you start preparing your migration for import**.\n\n6. To add more repositories to the same export, use the `ghe-migrator add` command with the `-g` flag. You'll pass in the new repository URL and the Migration GUID from Step 5:\n\n   ```shell\n   ghe-migrator add https://HOSTNAME/USERNAME/OTHER-REPO-NAME -g MIGRATION-GUID --lock\n   ```\n\n7. When you've finished adding repositories, generate the migration archive using the `ghe-migrator export` command with the `-g` flag and the Migration GUID from Step 5:\n\n   ```shell\n   $ ghe-migrator export -g MIGRATION-GUID\n   > Archive saved to: /data/github/current/tmp/MIGRATION-GUID.tar.gz\n   ```\n\n   * To specify where migration files should be staged append the command with `--staging-path=/full/staging/path`. Defaults to `/data/user/tmp`.\n\n8. Close the connection to GitHub.com:\n\n   ```shell\n   $ exit\n   > logout\n   > Connection to HOSTNAME closed.\n   ```\n\n9. Copy the migration archive to your computer using the [`scp`](https://acloudguru.com/blog/engineering/ssh-and-scp-howto-tips-tricks#scp) command. The archive file will be named with the Migration GUID:\n\n   ```shell\n   scp -P 122 admin@HOSTNAME:/data/github/current/tmp/MIGRATION-GUID.tar.gz ~/Desktop\n   ```\n\n10. To prepare the archived migration data for import into a GitHub Enterprise Server instance, see [Migrating data to GitHub Enterprise Server](/en/migrations/using-ghe-migrator/migrating-data-to-github-enterprise-server#preparing-the-migrated-data)."}