Search code examples
gitlabgitlab-api

importing a group to gitlabvia API


I am in the process of figuring out how to best migrate some projects from one instance of gitlab (let's call it gitlab.A.com) to another instance (call that one gitlab.B.com). Both are Gitlab Enterprise Edition 12.10.3-ee.

I would like to first export/import the group, preserving members, and then import/export projects. While this version of gitlab does provide Project Import/Export functionality in the web interface, the only way to do Group Import/Export is via the API.

By using the git API, I was able to successfully export a group from gitlab.A.com, generating a JSON file with all members. However, when I import that group to gitlab.B.com the members are not preserved - the group is created with only me as a member even though the exported file contains all members.

This is what I input at the command line to import to gitlab.B.com:

curl --request POST --header "PRIVATE-TOKEN: <my token>" --form "name=data-support" --form "path=data-support" --form "file=@/path_to_export/data_support_group.json" https://gitlab.B.com/api/v4/groups/import

Doing some research on this issue I think it might be that while I as group owner can export all the members, only an admin has permission to import a group preserving members and all settings - I am not an admin. Do you have any familiarity with this? I am really hoping to avoid adding each member manually to the new group.

Thank you!


Solution

  • I hate to say, using the Users API to create a user is the only solution (which does require an admin account) besides having all the users create their accounts ahead of time.

    Without admin access, this is similar to migrating from a GitLab instance to GitLab.com, where the docs call this out explicitly.

    For your reference, there is an existing feature request on allowing user mapping for non-admin imports.