Backup gitlab repositories to S3

Sgaunet
1 min readNov 14, 2021

--

Well, just the suite of the article concerning the backup of gitlab repositories. I’ve made another github project containing a Docker image to backup gitlab repositories and copy the archives to S3.

Everything is here.

gitlab-backup2s3

gitlab-backup2s3 is an enhanced docker image to export gitlab projects, encrypt the archive (optional) and save them in a S3.

Configuration

Need to setup some environment variables :

  • GOCRYPT_KEY (if you want to encrypt archives)
  • POSTBACKUP (if you want to encrypt archives, set it to: gocrypt enc — i %INPUTFILE% )
  • GITLAB_TOKEN
  • GITALB_URI (if the endpoint differs from https://gitlab.com)
  • GITLABPROJECTID: id of the project to export
  • GITLABGROUPID: id of the group to export (will export all sub projects)
  • DEBUGLEVEL: info by default
  • TMPDIR: /tmp by default
  • LOCALPATH: if you want to export archives locally (let empty if you prefer to copy archives to s3)
  • S3ENDPOINT: Example https://s3.eu-west-3.amazonaws.com or http://localhost:9090 for a local minio instance
  • S3REGION: region of s3
  • S3BUCKETNAME
  • S3BUCKETPATH
  • AWS_SECRET_ACCESS_KEY: not mandatory if you associate an IAM role to the pod or ec2
  • AWS_ACCESS_KEY_ID: not mandatory too

Example of deployment:

raw kubernetes manifests

In the deploy/k8s folder, you will find manifests to deploy a cronjob in kubernetes.

helm

Another github project contains the helm chart. This is https://github.com/sgaunet/helm-gitlab-backup2s3, check the README.

Configuration of the helm chart is available here.

--

--