All Projects → rvojcik → gitlab-project-export

rvojcik / gitlab-project-export

Licence: GPL-3.0 license
Simple python project for exporting GitLab projects with Export Project funkcionality in GitLab API. Import of exported projects is also supported

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to gitlab-project-export

geet
Command line interface for performing Git hosting service operations
Stars: ✭ 14 (-79.71%)
Mutual labels:  gitlab, gitlab-api
mmd-gitlab-backuper
a package to backup from all projects that you have on gitlab
Stars: ✭ 27 (-60.87%)
Mutual labels:  gitlab, gitlab-backup
gitlab-configuration-as-code
Manage GitLab configuration as code to make GitLab easily managable, traceable and reproducible.
Stars: ✭ 31 (-55.07%)
Mutual labels:  gitlab, gitlab-api
gitlabctl
Cross platform Gitlab management cli written in Go. Download the executable with no dependencies!
Stars: ✭ 41 (-40.58%)
Mutual labels:  gitlab, gitlab-api
Python Gitlab
Python wrapper for the GitLab API
Stars: ✭ 1,679 (+2333.33%)
Mutual labels:  gitlab, gitlab-api
gitlab-live
Interactive online shell for GitLab API
Stars: ✭ 21 (-69.57%)
Mutual labels:  gitlab, gitlab-api
gitlab.cr
Gitlab.cr is a GitLab API wrapper written by Crystal
Stars: ✭ 29 (-57.97%)
Mutual labels:  gitlab, gitlab-api
python-gitlab3
Python wrapper for the entire GitLab API
Stars: ✭ 44 (-36.23%)
Mutual labels:  gitlab, gitlab-api
gitlab-ci-runner-marathon
A customized Docker image for running scalable GitLab CI runners on Marathon
Stars: ✭ 14 (-79.71%)
Mutual labels:  gitlab
gitrows
A lightweight module for using git as a database
Stars: ✭ 212 (+207.25%)
Mutual labels:  gitlab
repobee
CLI tool for managing Git repositories on GitHub and GitLab in the context of education
Stars: ✭ 51 (-26.09%)
Mutual labels:  gitlab
grru
Gitlab Release Remover UI
Stars: ✭ 42 (-39.13%)
Mutual labels:  gitlab
pagination
Aplus Framework Pagination Library
Stars: ✭ 167 (+142.03%)
Mutual labels:  gitlab
Containerization-Automation
Study and Use of Containers and Automation Tools
Stars: ✭ 45 (-34.78%)
Mutual labels:  gitlab
froggit-go
Froggit-Go is a universal Go library, allowing to perform actions on VCS providers.
Stars: ✭ 19 (-72.46%)
Mutual labels:  gitlab
routing
Aplus Framework Routing Library
Stars: ✭ 186 (+169.57%)
Mutual labels:  gitlab
nebulous
The Kubefirst Open Source Platform
Stars: ✭ 122 (+76.81%)
Mutual labels:  gitlab
dash
Server control panel
Stars: ✭ 22 (-68.12%)
Mutual labels:  gitlab
code-examples-manager
Software tool to manage your notes and code examples, to publish them as gists or snippets
Stars: ✭ 26 (-62.32%)
Mutual labels:  gitlab
monorepo-split-github-action
Github Action for Monorepo Split
Stars: ✭ 56 (-18.84%)
Mutual labels:  gitlab

gitlab-project-export

Simple python project for exporting gitlab projects with Export Project feature in GitLab API.

Primarily useful for remote backup of projects in GitLab.com to private storage server.

Breaking Changes

05-2020

Code was modified to work with Python3, not longer compatible with Python2.

Prerequisite

Install

Simply install via pip:

pip install gitlab-project-export

or

pip install git+https://github.com/rvojcik/gitlab-project-export

or clone the project and install manually:

git clone https://github.com/rvojcik/gitlab-project-export
cd gitlab-project-export/
sudo python3 setup.py install

or use it without installing to your environment (install only requirements):

git clone https://github.com/rvojcik/gitlab-project-export
cd gitlab-project-export/
pip install -f requirements.txt

Usage

usage: gitlab-project-export.py [-h] [-c CONFIG] [-d] [-f]

optional arguments:
  -h, --help  show this help message and exit
  -c CONFIG   config file
  -d          Debug mode
  -f          Force mode - overwrite backup file if exists
usage: gitlab-project-import.py [-h] [-c CONFIG] [-f FILEPATH] [-p PROJECT_PATH] [-d]

optional arguments:
  -h, --help       show this help message and exit
  -c CONFIG        config file
  -f FILEPATH      Path to gitlab exported project file
  -p PROJECT_PATH  Project path
  -d               Debug mode

Prepare and edit your config file

mv config-example.yml config.yml

Simply run the script with optional config parameter

./gitlab-project-export.py -c /path/to/config.yml

Configuration

System uses simple yaml file as configuration.

Example below

gitlab:                                                   - gitlab configuration
  access:
    gitlab_url: "https://gitlab.com"                      - GitLab url, official or your instance
    token: "MY_PERSONAL_SECRET_TOKEN"                     - personal access token
  projects:                                               - list of projects to export
    - rvojcik/example-project

backup:                                                   - backup configuration
  destination: "/data/backup"                             - base backup dir
  project_dirs: True                                      - store projects in separate directories
  backup_name: "gitlab-com-{PROJECT_NAME}-{TIME}.tar.gz"  - backup file template
  backup_time_format: "%Y%m%d"                            - TIME template, use whatever compatible with
                                                            python datetime - date.strftime()
  retention_period: 3                                     - purge files in the destination older than the specified value (in days)

Backup Usecase in cron

Create cron file in /etc/cron.d/gitlab-backup

With following content

[email protected]

0 1 * * * root /path/to/cloned-repo/gitlab-project-export.py -c /etc/gitlab-export/config.yml

Migration Usecase

First create two config files

config1.yml for exporting our project from gitlab.com

gitlab:                                                   - gitlab configuration
  access:
    gitlab_url: "https://gitlab.com"                      - GitLab url, official or your instance
    token: "MY_PERSONAL_SECRET_TOKEN"                     - personal access token
  projects:                                               - list of projects to export
    - rvojcik/project1
    - rvojcik/project2

backup:                                                   - backup configuration
  destination: "/data/export-dir"                         - base backup dir
  backup_name: "gitlab-com-{PROJECT_NAME}-{TIME}.tar.gz"  - backup file template
  backup_time_format: "%Y%m%d"                            - TIME template, use whatever compatible with
                                                            python datetime - date.strftime()

and config2.yml where we need only gitlab access part for importing projects to private gitlab instance

gitlab:                                                   - gitlab configuration
  access:
    gitlab_url: "https://gitlab.privatedomain.tld"        - GitLab url, official or your instance
    token: "MY_PERSONAL_SECRET_TOKEN"                     - personal access token

Now it's time to export our projects

./gitlab-project-export.py -c ./config1.yml -d

Your projects are now exported in /data/export-dir

After that we use gitlab-project-import.py with config2.yml for importing into our pricate gitlab instance.

./gitlab-project-import.py -c ./config2.yml -f ./gitlab-com-rvojcik-project1-20181224.tar.gz -p "rvojcik/project1"
./gitlab-project-import.py -c ./config2.yml -f ./gitlab-com-rvojcik-project2-20181224.tar.gz -p "rvojcik/project2"

Done ;)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].