Sign inSign up

instantlinux/git-dump

By instantlinux

Updated 17 days ago

A git backup script wrapped in Alpine Linux.

Image
0

10K+

instantlinux/git-dump repository overview

git-dump

This dockerizes a simple script I wrote years ago to create git bundle backups of a private git server.

The example helm / docker-compose service definition will cause a dump of all accessible projects to happen at the default hour (0:45am in $TZ) from a GitLab server named git.instantlinux.net onto a subdirectory git in volume "backup".

Usage

Retention is set by a variable KEEP_DAYS which defaults to 31. Within the DEST_DIR you will then find a separate directory for each day of the month. If you set KEEP_DAYS to 7, it will keep a directory for each day of the week. Backups older than KEEP_DAYS will be automatically removed.

Provide a read-only private ssh key to access your git repo(s) in the Docker secret git-dump_sshkey. Github has an apparently-permanent and seemingly-arbitrary restriction against using the same read-only deploy key for more than one repo, so unless you specify the https access method, you will need to set up multiple instances of this container to backup more than one Github repo.

For GitLab, Bitbucket or other private repos, you can use this to back up an arbitrary number of git repos which share the same deploy key. This script supports the GitLab v3 API to read the list of projects at runtime, so you don't have to specify the REPOS parameter.

This repo has complete instructions for building a kubernetes cluster where you can deploy with helm or kubernetes.yaml using make and customizing Makefile.vars after cloning this repo:

git clone https://github.com/instantlinux/docker-tools.git
cd docker-tools/k8s
make git-dump
Variables

These variables can be passed to the image from kubernetes.yaml or docker-compose.yml as needed:

VariableDefaultDescription
API_TOKEN_SECRETNAMEdocker secret name of API token as below
DEST_DIR/var/backup/gitdestination path
HOUR0cron-syntax backup hour
KEEP_DAYS31days of snapshots to keep
MINUTE45cron-syntax minutes past hour
ORGorg in SCM
REPO_PREFIX[email protected]:instantlinux/prefix for each repository URI
REPOSrepository URIs to back up
SCM_TYPEgithubtype - github, gitlab, or gitea
SSHKEY_SECRETNAMEgit-dump_sshkeydocker secret name as below
SSH_PORT22TCP port of git service
TZUTCtime zone
Secrets
SecretDescription
git-dump_sshkeyread-only key for git repos (override name above)
xxx-api-tokenAPI token for fetching project list from gitlab
Contributing

If you want to make improvements to this image, see CONTRIBUTING.

Tag summary

Content type

Image

Digest

sha256:5d0a55621

Size

17.2 MB

Last updated

17 days ago

docker pull instantlinux/git-dump