Some scripts to export and import groups, projects and users from/to a gitlab instance.
You need some python dependencies to make it work:
Note: this script as not been tested so much, enhancements are welcome!
The gitlab-export.py
script exports a group wih all its projects and subprojects, given a group name. You must be owner of the group you want to export.
When using it, it generates a folder in exports/
with the name of the group, plus:
_group
folder containing all groups information
GROUP_NAME.tgz
: group name archivesubgroup\_projects\
folders containing all projects information
PROJECT_PATH__PROJECT_NAME.tgz
: project archive, given the name and pathNote: the folders are important, as every one created is associated to sub project
usage: gitlab-export.py [-h] -H HOSTNAME -t TOKEN -g GROUP [-o OUTPUT] [-d DELAY]
Gitlab project exporter
optional arguments:
-h, --help show this help message and exit
-H HOSTNAME, --hostname HOSTNAME
hostname of gitlab server
-t TOKEN, --token TOKEN
private token
-g GROUP, --group GROUP
root group
-o OUTPUT, --output OUTPUT
output folder
-d DELAY, --delay DELAY
delay between two download tentative
The gitlab-import.py
script import a group wih all its projects and subprojects, given a root group name. The group will be created under this one.
It uses same folder architecture than the export script.
usage: gitlab-import.py [-h] -H HOSTNAME -t TOKEN [-r ROOT] -i INPUT [-d DELAY]
Gitlab project importer
optional arguments:
-h, --help show this help message and exit
-H HOSTNAME, --hostname HOSTNAME
hostname of gitlab server
-t TOKEN, --token TOKEN
private token
-r ROOT, --root ROOT root group (must exists). Must not end with '/'
-i INPUT, --input INPUT
input path. Must end with '/'
-d DELAY, --delay DELAY
delay between two download tentative
The gitlab-users-export.py
exports users in a JSON format to a file, with the minimum required fields
usage: gitlab-users-export.py [-h] -H HOSTNAME -t TOKEN -o FILENAME
Gitlab users exporter
optional arguments:
-h, --help show this help message and exit
-H HOSTNAME, --hostname HOSTNAME
hostname of gitlab server
-t TOKEN, --token TOKEN
private token
-o FILENAME, --output FILENAME
filename
{
"email": "remi.verchere@axians.com",
"name": "Remi",
"username": "Verchere",
"bio": "",
"linkedin": "",
"twitter": "",
"organization": null,
"reset_password": true
}
The gitlab-users-import.py
import users from a JSON file, with the minimum required fields
usage: gitlab-users-import.py [-h] -H HOSTNAME -t TOKEN [-i INPUT]
Gitlab users exporter
optional arguments:
-h, --help show this help message and exit
-H HOSTNAME, --hostname HOSTNAME
hostname of gitlab server
-t TOKEN, --token TOKEN
private token
-i INPUT, --input INPUT
input file
Apache-2.0 License