An example migrating all ^odoo
repositories
pyenv virtualenv gitlab-project-transfer
pyenv activate gitlab-project-transfer
gitlab-project-export
git clone https://github.com/rvojcik/gitlab-project-export
cd gitlab-project-export/
pip install -r requirements.txt
nano config1.yml
#
# Gitlab configuration
#
# It is possible to use globbing in project names
# Example:
# - group/*
# - user/*/documentation
gitlab:
access:
gitlab_url: "https://gitlab.com"
token: "<redacted>"
# SSL verify
# Corresponds to verify option in request doc:
# https://2.python-requests.org/en/master/api/#requests.Session.merge_environment_settings
# Can be boolean to control whether we verify the ssl server certificate or string in which case it must be a path to CA bundle
# Default is True
# If you set it to False, you will get urllib warnings. To supress them, set environment variable:
# - export PYTHONWARNINGS="ignore:Unverified HTTPS request"
ssl_verify: True
projects:
- coopdevs/odoo*
# Membership attribute used when searching for projects
# If you want to export all projects from private gitlab instance
# use False here. In big shared instances or gitlab.com, use True
membership: True
# Wait Between Exports
# How many seconds to wait between projects to export.
# This is due rate-limiting in gitlab.com
# https://docs.gitlab.com/ee/user/project/settings/import_export.html#rate-limits
#
# If you break the limit, API responds with 429 for your IP address for a while.
#
# When you are using this in your private gitlab instance, you can set it to 0
wait_between_exports: 60
# Maximum Retries
# Number of times to retry, if the export fails
max_tries_number: 1
#
# Backup configuration
#
backup:
# Destination of the exports/backups
destination: "/data/gitlab"
# Create separate directory for every project
project_dirs: True
# Backup Name template
# It is possible to use some placeholders in the name
# {PROJECT_NAME} - Name of the project with full path
# Path slashes are replaced with dashes.
# Example:
# rvojcik/project1 => rvojcik-project1
#
# {TIME} - Time of the export
backup_name: "gitlab-com-{PROJECT_NAME}-{TIME}.tar.gz"
# Time format template
# Time is constructed by python strftime.
# backup_time_format can be anything compatible with strftime
# Blank spaces are replaced with underscores.
# Example:
# %Y%m%d %H%M => %Y%m%d_%H%M
backup_time_format: "%Y%m%d"
# Retention period (in days)
# backup files older than this period will be deleted
# retention_period can be any positive number
# specify 0 if you want to skip the deletion
retention_period: 0
sudo ./gitlab-project-export.py -c ./config1.yml -d
vi config2.yml
gitlab:
access:
gitlab_url: "https://git.coopdevs.org"
token: "MY_PERSONAL_SECRET_TOKEN"
massive_import
scriptvi massive_import.sh
#!/bin/bash
folder=/data/gitlab/coopdevs/
repos=$(ls -1 $folder)
for repo in $repos; do
project_path="coopdevs/migrated-projects/$repo"
tar=$(ls $folder$repo)
file=$folder$repo/$tar
echo "Importing $file"
sudo ./gitlab-project-import.py -c ./config2.yml -f $file -p "$project_path"
done;
python-gitlab
cd ..
pip install --upgrade python-gitlab
Configure python-gitlab
:
vi ~/.python-gitlab.cfg
[global]
default = gitlab
ssl_verify = true
timeout = 30
[gitlab]
url = https://gitlab.com
private_token = <redacted>
api_version = 4
gitlab group-project list --all --group-id 2782238 | awk -v col=2 '{print $col}' | xargs -I _ gitlab project get --id _ > named_projects.txt
cat named-projects.txt | egrep "^odoo" -A1 > odoo-projects.txt
cat odoo-projects.txt | egrep "[0-9]" > odoo_ids.txt
Migrated projects
subgroupcat odoo_ids.txt | xargs -I _ gitlab -c ~/.python-gitlab.cfg project transfer --id _ --to-namespace 53568386 && sleep 10