Backup script for Gitlab with CRON and docker support
282
A dockerized Gitlab backup script to :
Edit vars-template (environment variables) :
| Variable name | description | default value |
|---|---|---|
| KEY_SSH_RSA | SSH RSA key | |
| KEY_ECDSA | SSH ECDSA key | |
| KEY_ED25519 | SSH ED25519 key | |
| PRIVATE_TOKEN | token used to call Gitlab API (personnal access token) | |
| GITLAB_USERNAME | gitlab username for retrieving individual repository | |
| GITLAB_PASSWORD | gitlab password for retrieving individual repository | |
| GITLAB_DOMAIN | Gitlab server domain name | gitlab.com |
| GITLAB_PORT | port to be used for Gitlab API | 443 |
| GITLAB_SSH_PORT | ssh port | 22 |
| PROJECT_MAX_NUMBER | max number of repos to be backed up | 300 |
| BACKUP_DIR | directory when backup projects are transfered | /home/backup |
| RETAIN_TIME | retaining time in days | 30 |
KEY_SSH_RSA,KEY_ECDSA and KEY_ED25519 should be specified to prevent man-in-the-middle attack, you can get those with :
ssh-keyscan -p $GITLAB_SSH_PORT $GITLAB_DOMAIN
PRIVATE_TOKEN is a personnal access token
source vars-template
./backup.sh
docker run -e "GITLAB_DOMAIN=my.gitlab.com" \
-e "KEY_SSH_RSA=ssh-rsa XXXXXXX" \
-e "KEY_ECDSA=ecdsa-sha2-nistp256 XXXXXX" \
-e "KEY_ED25519=ssh-ed25519 XXXXXXXXXXXXXXx" \
-e "PRIVATE_TOKEN=xZqsf-azsdllqmoaze" \
-e "GITLAB_USERNAME=john" \
-e "GITLAB_PASSWORD=changeme" \
-v /home/user/backup:/home/backup bertrandmartel/gitlab-backup
source vars-template
envsubst < docker-compose-template.yml > docker-compose.yml
docker-compose up
source vars-template
envsubst < stackfile-template.yml > stackfile.yml
docker-cloud stack crate --name gitlab-backup -f stackfile.yml
Content type
Image
Digest
Size
84.4 MB
Last updated
almost 8 years ago
docker pull bertrandmartel/gitlab-backup