Skip to main content

此版本的 GitHub Enterprise 已停止服务 2022-06-03. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

Exporting migration data from your enterprise

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.

Preparing the GitHub Enterprise Server source instance

  1. 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.

  2. 生成范围为 repoadmin:org 的访问令牌。 on the GitHub Enterprise Server source instance.

  3. 为尽量减少停机,请创建要从源实例导出的仓库列表。 您可以使用每行列出一个仓库 URL 的文本文件一次性导出多个仓库。

Exporting the GitHub Enterprise Server source repositories

注意: 锁定存储库会阻止对存储库的所有写入。 您不能将新团队或协作者与锁定的仓库相关联。 如果您执行的试用版,则� 需锁定仓库。 当您从正在使用的仓库迁移数据时,

GitHub 强烈建议锁定仓库。 更多信息请参阅“关于迁移”。

  1. SSH 连接到 您的 GitHub Enterprise Server 实例。 更多信息请参阅“访问管理 shell (SSH)。”

    $ ssh -p 122 admin@HOSTNAME
  2. To prepare a repository for export, use the ghe-migrator add command with the repository's URL:

    • If you're locking the repository, append the command with --lock. If you're performing a trial run, --lock is not needed.
      $ ghe-migrator add https://hostname/username/reponame --lock
    • You can exclude file attachments by appending --exclude_attachments to the command. 文件附件可能很大,可能不必要地胀大您的最终迁移存档。
    • 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.
      $ ghe-migrator add -i PATH/TO/YOUR/REPOSITORY_URLS.txt
  3. When prompted, enter your GitHub Enterprise Server username:

    Enter username authorized for migration:  admin
  4. When prompted for a personal access token, enter the access token you created in "Preparing the GitHub Enterprise Server source instance":

    Enter personal access token:  **************
  5. 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.

    > 101 models added to export
    > Migration GUID: example-migration-guid
    > Number of records in this migration:
    > users                        |  5
    > organizations                |  1
    > repositories                 |  1
    > teams                        |  3
    > protected_branches           |  1
    > pull_request_reviews         |  1
    > milestones                   |  1
    > issues                       |  3
    > pull_requests                |  5
    > pull_request_review_comments |  4
    > commit_comments              |  2
    > issue_comments               | 10
    > issue_events                 | 63
    > releases                     |  3
    > attachments                  |  4
    > projects                     |  2

    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.

  6. If you locked the source repository, you can use the ghe-migrator target_url command to set a custom lock message on the repository page that links to the repository's new location. Pass the source repository URL, the target repository URL, and the Migration GUID from Step 5:

    $ ghe-migrator target_url https://hostname/username/reponame https://target_hostname/target_username/target_reponame -g MIGRATION_GUID
  7. 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:

    $ ghe-migrator add https://hostname/username/other_reponame -g MIGRATION_GUID --lock
  8. 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:

    $ ghe-migrator export -g MIGRATION_GUID
    > Archive saved to: /data/github/current/tmp/MIGRATION_GUID.tar.gz
    • 要指定迁移文件的暂存位置,请在命令行附�  --staging-path=/full/staging/path。 默认值为 /data/user/tmp
  9. Close the connection to 您的 GitHub Enterprise Server 实例:

    $ exit
    > logout
    > Connection to hostname closed.
  10. Copy the migration archive to your computer using the scp command. The archive file will be named with the Migration GUID:

    $ scp -P 122 admin@hostname:/data/github/current/tmp/MIGRATION_GUID.tar.gz ~/Desktop
  11. 要将存档的迁移数据导入到 GitHub Enterprise Server 实例,请参阅“准备将数据迁移到企业”。