Skip to main content

Easy migration between GitLab instances for specific group with it's repositories and subgroups.

Project description

g2g: GitLab to GitLab Group Migrator

g2g is a Python CLI utility designed to streamline the process of migrating groups, and subgroups from one GitLab instance to another.

Features

  • Migrate entire group with his nested subgroups/repositories.
  • Works with private and public repositories.
  • Handles existing groups and repositories elegantly.
  • Generate a JSON backup of Group metadata.
  • Token-based authentication for security.

Installation

You can install the package from PyPI:

pip install g2g

Usage

Basic usage:

The primary commands for g2g are download and upload.

g2g download --api-url "https://gitlab.com/api/v4" --group "mloops" --clean-all
Please enter your GitLab Private Token: 
Removing existing group directory: mloops
Cloning devops-within...
Cloning devops-brother...
Downloading subgroup devops-card
Cloning devops-Mr...
Downloading subgroup devops-animal
Cloning devops-life...
Downloading subgroup devops-home
Cloning devops-free...
Downloading subgroup devops-recently
Cloning devops-leave...
Cloning devops-trouble...
Downloading subgroup devops-time
Cloning devops-while...
Downloading subgroup devops-girl
Cloning devops-hotel...
g2g upload --api-url https://new.instance.localhost/api/v4 --group mloops
Please enter your GitLab Private Token for the new instance: 
{
    "devops-brother": {
        "path": "mloops/devops-brother"
    },
    "devops-trouble": {
        "path": "mloops/devops-home/devops-recently/devops-trouble"
    },
    "devops-leave": {
        "path": "mloops/devops-home/devops-recently/devops-leave"
    },
    "devops-free": {
        "path": "mloops/devops-home/devops-free"
    },
    "devops-while": {
        "path": "mloops/devops-time/devops-while"
    },
    "devops-hotel": {
        "path": "mloops/devops-time/devops-girl/devops-hotel"
    },
    "devops-within": {
        "path": "mloops/devops-within"
    },
    "devops-life": {
        "path": "mloops/devops-card/devops-animal/devops-life"
    },
    "devops-Mr": {
        "path": "mloops/devops-card/devops-Mr"
    }
}
Processing devops-brother with path parts: ['mloops', 'devops-brother']
Group specified. Updated path parts: ['mloops', 'devops-brother']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating new project: devops-brother under parent ID: 3283
Successfully created and pushed to https://new.instance.localhost/mloops/devops-brother.git
Processing devops-trouble with path parts: ['mloops', 'devops-home', 'devops-recently', 'devops-trouble']
Group specified. Updated path parts: ['mloops', 'devops-home', 'devops-recently', 'devops-trouble']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating or getting group: devops-home
Group devops-home created or fetched with ID: 3285
Creating or getting group: devops-recently
Group devops-recently created or fetched with ID: 3286
Creating new project: devops-trouble under parent ID: 3286
Successfully created and pushed to https://new.instance.localhost/mloops/devops-home/devops-recently/devops-trouble.git
Processing devops-leave with path parts: ['mloops', 'devops-home', 'devops-recently', 'devops-leave']
Group specified. Updated path parts: ['mloops', 'devops-home', 'devops-recently', 'devops-leave']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating or getting group: devops-home
Group devops-home created or fetched with ID: 3285
Creating or getting group: devops-recently
Group devops-recently created or fetched with ID: 3286
Creating new project: devops-leave under parent ID: 3286
Successfully created and pushed to https://new.instance.localhost/mloops/devops-home/devops-recently/devops-leave.git
Processing devops-free with path parts: ['mloops', 'devops-home', 'devops-free']
Group specified. Updated path parts: ['mloops', 'devops-home', 'devops-free']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating or getting group: devops-home
Group devops-home created or fetched with ID: 3285
Creating new project: devops-free under parent ID: 3285
Successfully created and pushed to https://new.instance.localhost/mloops/devops-home/devops-free.git
Processing devops-while with path parts: ['mloops', 'devops-time', 'devops-while']
Group specified. Updated path parts: ['mloops', 'devops-time', 'devops-while']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating or getting group: devops-time
Group devops-time created or fetched with ID: 3290
Creating new project: devops-while under parent ID: 3290
Successfully created and pushed to https://new.instance.localhost/mloops/devops-time/devops-while.git
Processing devops-hotel with path parts: ['mloops', 'devops-time', 'devops-girl', 'devops-hotel']
Group specified. Updated path parts: ['mloops', 'devops-time', 'devops-girl', 'devops-hotel']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating or getting group: devops-time
Group devops-time created or fetched with ID: 3290
Creating or getting group: devops-girl
Group devops-girl created or fetched with ID: 3292
Creating new project: devops-hotel under parent ID: 3292
Successfully created and pushed to https://new.instance.localhost/mloops/devops-time/devops-girl/devops-hotel.git
Processing devops-within with path parts: ['mloops', 'devops-within']
Group specified. Updated path parts: ['mloops', 'devops-within']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating new project: devops-within under parent ID: 3283
Successfully created and pushed to https://new.instance.localhost/mloops/devops-within.git
Processing devops-life with path parts: ['mloops', 'devops-card', 'devops-animal', 'devops-life']
Group specified. Updated path parts: ['mloops', 'devops-card', 'devops-animal', 'devops-life']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating or getting group: devops-card
Group devops-card created or fetched with ID: 3295
Creating or getting group: devops-animal
Group devops-animal created or fetched with ID: 3296
Creating new project: devops-life under parent ID: 3296
Successfully created and pushed to https://new.instance.localhost/mloops/devops-card/devops-animal/devops-life.git
Processing devops-Mr with path parts: ['mloops', 'devops-card', 'devops-Mr']
Group specified. Updated path parts: ['mloops', 'devops-card', 'devops-Mr']
Creating or getting group: mloops
Group mloops created or fetched with ID: 3283
Creating or getting group: devops-card
Group devops-card created or fetched with ID: 3295
Creating new project: devops-Mr under parent ID: 3295
Successfully created and pushed to https://new.instance.localhost/mloops/devops-card/devops-Mr.git

Additional Options:

  • --token TEXT The GitLab Private Token for CI/CD
  • --output-file to specify the JSON file for saving repo information.
  • --input-file to specify the JSON file for reading repo information.
  • --clean-all to remove all existing repos before download.

Contributing

All contributions are welcome! Please refer to the CONTRIBUTING.md for guidelines.

License

MIT Licensed. See LICENSE for full details.

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

g2g-0.1.5.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

g2g-0.1.5-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file g2g-0.1.5.tar.gz.

File metadata

  • Download URL: g2g-0.1.5.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.5.0-45-generic

File hashes

Hashes for g2g-0.1.5.tar.gz
Algorithm Hash digest
SHA256 d2e5d3f4043a5981b22d984620ad031da335febb16b80e5a03e8365d93fb7228
MD5 ac803d24cb136de3ad720488e745231e
BLAKE2b-256 0979de25a11986c09b59d185741931b5b58094e686112aeb7aaaa40f8da85408

See more details on using hashes here.

File details

Details for the file g2g-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: g2g-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.5.0-45-generic

File hashes

Hashes for g2g-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c2a8d0387657d926fec34ebade45a2b4b6a96176ba9dd7a2101437659d847582
MD5 6ccdaf52edc7b77187715c4a6f30a824
BLAKE2b-256 6c418cd4c53c7e05c5f0355bdd2e2edd49f94447e6359a9bc3151ea7efe34c34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page