Skip to content

CLI tool for backing up GitLab projects and groups. Exports projects via GitLab API to local storage or AWS S3, with support for concurrent exports, rate limiting, and pre/post backup hooks. Features clean architecture, comprehensive testing, and Docker support.

License

Notifications You must be signed in to change notification settings

sgaunet/gitlab-backup

Repository files navigation

GitHub release Go Report Card GitHub Downloads Test Coverage GoDoc Linter Release Snapshot License

gitlab-backup

This tool can be used to export project or every projects of a gitlab group. It uses the API of gitlab to get an archive of exported project.

Two options to save the exported projects:

  • local folder
  • s3

There is also the possibility to specify pre/post backup hooks.

Usage by configuration file

Example:

# debuglevel: "info"
gitlabGroupID: XXXX
gitlabProjectID: YYYY
localpath: "/backup"
gitlabtoken: 
# gitlaburi: https://gitlab.com
# tmpdir: /tmp
# exportTimeoutMins: 10  # Export timeout in minutes (default: 10, increase for large projects)
hooks:
    prebackup: ""
    postbackup: ""
s3cfg:
  endpoint: "http://localhost:9090"
  bucketName: "ephemeralfiles"
  bucketPath: "test"
  region: "us-east-1"
  accesskey: ""
  secretkey: ""

parameters of the configuration file can be override by environment variable

Launch the program: gitlab-backup -c configuration.yaml

Usage by environment variable

  AWS_ACCESS_KEY_ID string
  AWS_SECRET_ACCESS_KEY string
  EXPORT_TIMEOUT_MIN int
         (default "10")
  GITLABGROUPID int
         (default "0")
  GITLABPROJECTID int
         (default "0")
  GITLAB_TOKEN string
  GITLAB_URI string
         (default "https://gitlab.com")
  LOCALPATH string
         (default "")
  POSTBACKUP string
         (default "")
  PREBACKUP string
         (default "")
  S3BUCKETNAME string
         (default "")
  S3BUCKETPATH string
         (default "")
  S3ENDPOINT string
         (default "")
  S3REGION string
         (default "")
  TMPDIR string
         (default "/tmp")

Extended project

Another project can be used to encrypt archives of exported project and send them to s3. It's gitlab-backup2s3 which is using two softwares:

  • gitlab-backup (this project)
  • gocrypt

Installation

Release

Download the latest release from github and install it.

## Brew

brew tap sgaunet/homebrew-tools
brew install sgaunet/tools/gitlab-backup

Development

This project is using :

Use task to compile/create release...

$ task
task: [default] task -a
task: Available tasks for this project:
* build:            Build the binary
* default:          List tasks
* doc:              Start godoc server
* image:            Build/push the docker image
* release:          Create a release
* snapshot:         Create a snapshot release
* update-crt:       Update the crt file

About

CLI tool for backing up GitLab projects and groups. Exports projects via GitLab API to local storage or AWS S3, with support for concurrent exports, rate limiting, and pre/post backup hooks. Features clean architecture, comprehensive testing, and Docker support.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors 2

  •  
  •