Skip to content

lechuckroh/gitlab-migration

Repository files navigation

gitlab-migration

docker image

Migrate GitLab repositories to other GitLab server

Requirements

  • Python 3

Configuration

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 connection
  • ssl_verify: verify the SSL certificate
  • timeout: Number of seconds to wait for an answer before failing.

Override with env

Tou can override existing configurations using environment variables.

variable name prefix:

  • GITLAB_SRC_: src group variables
  • GITLAB_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

Run

Run from source

# 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 is False
  • GITLAB_IMPORT_OVERWRITE: default value is False
    • True: overwrite existing dest project.
    • False: throws exception if dest project exists.

You can find Group ID at 'group overview' page.

Run with docker image

$ GITLAB_SRC_GROUP_ID={srcGroupId} GITLAB_DEST_GROUP_ID={destGroupId} \
  docker-compose run --rm lechuckroh/gitlab-migration

Limitations

migration items

The following items are migrated if use_export is False.

item support
git O
issues
labels
pipelines
runners
settings
snippets
wiki

About

Migrate GitLab repositories to other GitLab server

Resources

License

Stars

Watchers

Forks

Packages

No packages published