Skip to main content

CLI tool for dump Gitlab projects

Project description

Gitlab dumper

A simple CLI tool for creating a dump of all projects in your Gitlab instance.

Supports dump as raw repo and archives.

Preflight

Go to https://<YOUR_GITLAB_ENDPOINT>/-/profile/personal_access_tokens and create personal token with permissions:

  • api
  • read_api
  • read_repository

If you want to see all repositories, it may make sense to grant administrator permissions for the access token.

Configuration

Create .env file and put credentials:

LOG_LEVEL="info"
GITLAB_URL="https://<YOUR_GITLAB_ENDPOINT>"
GITLAB_PERSONAL_TOKEN="xxxxxx"  # also, GITLAB_OAUTH_TOKEN supports

Or set environment variables directly:

export LOG_LEVEL="info"
export GITLAB_URL="https://<YOUR_GITLAB_ENDPOINT>"
export GITLAB_PERSONAL_TOKEN="xxxxxx"

Requirements:

  • Python >= 3.10
  • The git command line tool must be installed on your PC
  • The utility clones over SSH, so make sure that your public key is added to the GitLab profile, read the doc
    • If you are having problems with the SSH key, just run the dump command with the --as-archive flag, it does not require SSH.

Install

Using pip:

python3 -m venv venv
source venv/bin/activate
pip install gitlab-dumper

gitlab-dumper --help

Installing from source:

git clone https://github.com/akimrx/gitlab-dumper  --recursive
cd gitlab-dumper
python3 -m venv venv
source venv/bin/activate
make install  # or: python3 setup.py install

gitlab-dumper --help

Usage

Commands:
  groups    Operations with Gitlab groups.
  projects  Operations with Gitlab projects.
  tree      Show groups, subgroups and projects as tree.

Groups commands:
  list      Show available Gitlab groups.
  projects  List projects in group or subgroup.

Projects commands:
  dump  Download, clone or re-pull all available projects.
  list  Show available Gitlab projects.

Dump

Before really dump use --dry-run flag, for example:

gitlab-dumper projects dump --namespaces foo,bar --no-personal --dry-run

For full dump just use gitlab-dumper projects dump

Available optional flags:

  --dumps-dir TEXT   Directory for dumps (default: ./dumps).
  --delay INTEGER    Delay between clones in seconds (default 0).
  --skip-empty       Ignore empty projects.
  --no-personal      Ignore personal user projects.
  --as-archive       Download projects as tar.gz archive instead clone.
  --dry-run          Safe simulate dump without download/clone.
  --namespaces TEXT  Comma-separated namespaces to operate.
  --exclude TEXT     Comma-separated projects (slug) to exclude.
  --help             Show this message and exit.

Development run

python3 -m 'src.main' --help

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

gitlab-dumper-0.1.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

gitlab_dumper-0.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file gitlab-dumper-0.1.1.tar.gz.

File metadata

  • Download URL: gitlab-dumper-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for gitlab-dumper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bc58fd0e0b0a85a4f1aa2f71444ae0053f0aa4bee98ef9170778da23457eb391
MD5 e027ae63a444fd82a7a1c35bc09fd02b
BLAKE2b-256 741a40925d5b895707129389403d0274c876eb19802b6cf2c24aceb823f3bf69

See more details on using hashes here.

File details

Details for the file gitlab_dumper-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gitlab_dumper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 302d6d3f642188f008900c20819e998b53fd33d84b705c8f28d6d333b1e3ff0d
MD5 608c31f3ec845b10bc782c9b193fdcdd
BLAKE2b-256 79fc46ef6f3141aaa5a24e74745042c9311dcc4c8f0a0353b94c59eddd1c5720

See more details on using hashes here.

Supported by

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