Mirror your GItLab account to a directory of bare Git repos.
175
I'm running my own GitLab instance at home, but I'm less than enthused about the way GitLab handles backups. I'd previously used Duplicity to back up a directory full of bare Git repos to cloud storage, with a monthly full backup and daily incremental backups. This doesn't mesh too well with the way GitLab does backups; as near as I can tell, the incremental backups end up being as close to full backups as makes no difference.
This package allows you to mirror your GitLab repos into a directory of bare Git repos that can more easily be backed up.
If you're running this on bare metal, you only need all_repos.py and update.sh. You'll need to set a couple of environment variables:
URL: the URL of your GitLab instance (might also work with gitlab.com,
but this is untested)APIKEY: the API key for the GitLab account you want to syncYou might also want to tweak the second line in update.sh to point to the directory where you want the repos to be stored.
Since my GitLab server and Duplicity backups are running on a container host, I've also bundled this up so that you can easily use it there. In that case, you can invoke it with something like this:
docker run -it --rm -v /home/salfter/git:/git -v /home/salfter/.ssh:/ssh -e URL=https://gitlab.alfter.us -e APIKEY=[REDACTED] -e UID=1000 -e GID=1000 salfter/gitlab-repo-sync
Let's break down what's happening within:
-v /home/salfter/git:/git: The directory where you want your repos to
go gets mapped to /git.-v /home/salfter/.ssh:/ssh: The directory with the SSH key you use
with your GitLab server needs to be mapped to /ssh.-e URL=https://gitlab.alfter.us -e APIKEY=[REDACTED]: These are set
as described above.-e UID=1000 -e GID=1000: Set the user and group IDs to match the owner
of your bare-repo directory.This project is maintained at https://gitlab.alfter.us/salfter/gitlab-repo-sync.
Content type
Image
Digest
sha256:01fbab2fb…
Size
35.5 MB
Last updated
over 2 years ago
docker pull salfter/gitlab-repo-sync