Migration of project and group
Useful python migration tools
Author: Donghee Kang, donghee.kang@kit.edu. Felix Dörre, felix.doerre@kit.edu
Requirement
python-gitlab
requires Python 3.8+
at least.
Use pip to install the latest stable version of python-gitlab
pip install --upgrade python-gitlab pip install tqdm
1. Group from pilot gitlab to new GitLab at KIT
Usage: migration_group_export_import.py
- add your personal access token (PAT) getting from the source and target gitlab both.
- In source(pilot) gitlab, find out the group id, which will be migrated. You should access it from the web browser.
- In target(new) gitlab, define the `path`` of your subgroup. (not group name)
group_namespace_in_target = 'kit/institute/my_group'
In the target gitlab, a group structure "KIT / Institute" has to be eanbled in advance. If the last subgroup "my_group" is not existing, "my_group" will be created first and projects wil be transferred on this subgroup. If the last subgroup "my_group" is already existing, then all projects will be transferred to existing subgroup, directly.
$ python3 migration_group_export_import.py
Procedure:
- Exporting projects in a group
my_group
from the source gitlab. You needs to knowgroup_id
for this groupmy_group
- Download exported files to the local directory
"{PWD}/exported_files"
- Importing the exported files to the target gitlab on
"kit/institute/my_group"

2. Exported project files transfer to the Group on new GitLab at KIT
Usage: migration_group_import_only.py
- add your personal access token (PAT) getting from the target gitlab only.
- define a set of exported files, that are located under the local directory
"{PWD}/exported_files"
- In target(new) gitlab, define the path of your subgroup
group_namespace_in_target = 'kit/institute/my_group'
In the target gitlab, a group structure "KIT / Institute" has to be eanbled in advance. If the last subgroup "my_group" is not existing, "my_group" will be created first and projects wil be transferred on this subgroup. If the last subgroup "my_group" is already existing, then all projects will be transferred to existing subgroup, directly.
$ python3 migration_group_improt_only.py
Procedure:
- No exporting and download is requried. In the directory
"{PWD}/exported_files"
all*_exported.tar.gz"
files(=projects) are enabled to use. - Importing the exported files to the target gitlab on the subgroup
"kit/institute/my_group"
3. Project from pilot gitlab to new GitLab at KIT
Usage: migration_project_export_improt.py
- add your personal access token (PAT) getting from the source and target gitlab both.
- In source(pilot) gitlab, find the project id or project namespace.
project_id_in_source = 123456789
source_namespace = 'xx1234/my_project'
- In target(new) gitlab, define the private namespace. It would be <vornaem.nachname> in general.
target_namespace = 'firstname.lastname'
If project_id_in_source is used, you do not need to defind source_namespace. But if you do not use project_id_in_source, then you have to write the project namespace(path) explicitly. For the target namespace, you have to define your private namespace as default, where the project will be transferred.
$ python3 migration_group_export_import.py
Procedure:
- Exporting a single project from the source gitlab.
- Download exported file to the local directory
"{PWD}/exported_files"
- Importing the exported file to the target gitlab on private namesapce
"firstname.lastname"