Skip to content

Instantly share code, notes, and snippets.

@wirwolf
Created December 16, 2023 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wirwolf/f7ee8ebb41a3e51ea18f6ab0350837a4 to your computer and use it in GitHub Desktop.
Save wirwolf/f7ee8ebb41a3e51ea18f6ab0350837a4 to your computer and use it in GitHub Desktop.
gitlab-utils.sh
#!/usr/bin/env bash
set -eu
export BACKUP_FOLDER=/opt/gitlab/data/backups
export CONTAINER_NAME=gitlab
echo "[$(date)] remove old backup"
find ${BACKUP_FOLDER} -name '*_gitlab_backup.tar' -delete -print
rm -v ${BACKUP_FOLDER}/gitlab_backup.tar.sha512sum || true
rm -v ${BACKUP_FOLDER}/gitlab_backup.log || true
echo "[$(date)] create new backup"
docker-compose exec -it ${CONTAINER_NAME} gitlab-backup create SKIP=registry > ${BACKUP_FOLDER}/gitlab_backup.log
echo "[$(date)] create sha512sum "
find ${BACKUP_FOLDER} -name '*_gitlab_backup.tar' -exec sha512sum {} + > ${BACKUP_FOLDER}/gitlab_backup.tar.sha512sum
echo "[$(date)] done"
#!/usr/bin/env bash
set -eu
export CONTAINER_NAME=gitlab
echo "[$(date)] Start cleaning registry"
echo "[$(date)] Remove unreferenced layers"
docker-compose exec -it ${CONTAINER_NAME} gitlab-ctl registry-garbage-collect > /dev/null
echo "[$(date)] Remove untagged manifests and unreferenced layers"
docker-compose exec -it ${CONTAINER_NAME} gitlab-ctl registry-garbage-collect -m > /dev/null
echo "[$(date)] Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment