Migrate GitLab repositories to other GitLab server
- Python 3
Open python-gitlab.cfg
file and change src
and dest
sections.
You can create private token at Personal Access Tokens menu.
See python-gitlab Configuration for detailed configuration description.
default
: source gitlab connectionssl_verify
: verify the SSL certificatetimeout
: Number of seconds to wait for an answer before failing.
Tou can override existing configurations using environment variables.
variable name prefix:
GITLAB_SRC_
:src
group variablesGITLAB_DEST_
:dest
group variables
variable name and configuration mapping:
env name | configuration |
---|---|
SSL_VERIFY |
ssl_verify |
TIMEOUT |
timeout |
PRIVATE_TOKEN |
private_token |
HTTP_USERNAME |
http_username |
HTTP_PASSWORD |
http_password |
OAUTH_TOKEN |
oauth_token |
JOB_TOKEN |
job_token |
# setup virtual environments
$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ python -m pip install pip-tools
(venv) $ pip install -r requirements.txt
# Migrate
$ GITLAB_SRC_GROUP_ID=1234 \
GITLAB_DEST_GROUP_ID=5678 \
python migrate.py
# Migrate using export/import
$ GITLAB_EXPORT_IMPORT=True \
GITLAB_SRC_GROUP_ID=1234 \
GITLAB_DEST_GROUP_ID=5678 \
python migrate.py
# Migrate using export/import. overwrite existing project if exists.
$ GITLAB_EXPORT_IMPORT=True \
GITLAB_IMPORT_OVERWRITE=True \
GITLAB_SRC_GROUP_ID=1234 \
GITLAB_DEST_GROUP_ID=5678 \
python migrate.py
Environments:
GITLAB_SRC_GROUP_ID
: source gitlab group id (required)GITLAB_DEST_GROUP_ID
: destination gitlab group id (required)GITLAB_EXPORT_IMPORT
: default value isFalse
True
: migrate projects using export/import. See Project import/export API for detail limitations.False
: migrate projects item by item. See Limitations for detail limitations.
GITLAB_IMPORT_OVERWRITE
: default value isFalse
True
: overwrite existing dest project.False
: throws exception if dest project exists.
You can find Group ID at 'group overview' page.
$ GITLAB_SRC_GROUP_ID={srcGroupId} GITLAB_DEST_GROUP_ID={destGroupId} \
docker-compose run --rm lechuckroh/gitlab-migration
The following items are migrated if use_export
is False
.
item | support |
---|---|
git | O |
issues | |
labels | |
pipelines | |
runners | |
settings | |
snippets | |
wiki |