Skip to content

Instantly share code, notes, and snippets.

@travelhawk
Created February 2, 2022 11:07
Show Gist options
  • Save travelhawk/2f2bc3a82ecd2acd037157025268ea49 to your computer and use it in GitHub Desktop.
Save travelhawk/2f2bc3a82ecd2acd037157025268ea49 to your computer and use it in GitHub Desktop.
Crontab with maintainence tasks for self-managed GitLab instance (docker setup)
# Crontab for Self-Managed GitLab instance
# ----------------------------------------
# Edit with (sudo) crontab -e
## mail errors to email
MAILTO=email@domain.de
## prune unused image to reduce space
@daily docker image prune -f > /dev/null
## daily gitlab backup at night (app & config/secrets)
0 2 * * * docker exec -t gitlab_web_1 gitlab-backup create > /dev/null
0 3 * * * docker exec -t gitlab_web_1 gitlab-ctl backup-etc --delete-old-backups > /dev/null
## upload backup to backup server
0 4 * * * cd /home/htects/gitlab && ./upload_backups.sh > /dev/null
## remove unused docker layers in GitLab (every sunday)
30 4 * * 0 docker exec -t gitlab_web_1 gitlab-ctl registry-garbage-collect -m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment