Skip to main content

Gitlab Server

Installation

With Docker
mkdir /mygitlab

docker run --detach \
  --hostname  mygit.example.com\
  --publish 80:80 \
  --name gitlab \
  --restart always \
  --volume /mygitlab/config:/etc/gitlab \
  --volume /mygitlab/logs:/var/log/gitlab \
  --volume /mygitlab/data:/var/opt/gitlab \
  --privileged \
  gitlab/gitlab-ce:17.11.7-ce.0

Backup & Restore

With Docker

# Backup
docker exec -it <container-name> gitlab-backup create
# Backup DB only
docker exec -it <container-name> gitlab-backup create SKIP=artifacts,repositories,registry,uploads,builds,pages,lfs,packages,terraform_state

# Verify the backup file
docker exec -it <container-name> ls  /var/opt/gitlab/backups

# Restore
docker exec -it <container-name> bash
> gitlab-ctl stop puma
> gitlab-ctl stop sidekiq
> gitlab-ctl status

> gitlab-backup restore BACKUP=1704810663_2024_01_09_17.11.1
# Restore DB only
> gitlab-backup restore BACKUP=1704810663_2024_01_09_17.11.1 SKIP=artifacts,repositories,registry,uploads,builds,pages,lfs,packages,terraform_state

> gitlab-ctl restart
> gitlab-rake gitlab:check SANITIZE=true
> gitlab-rake gitlab:artifacts:check
> gitlab-rake gitlab:lfs:check
> gitlab-rake gitlab:uploads:check

# Restart the container
docker restart <container-name>

Upgrade & Patch

Pre-upgrade and post-upgrade checks
    https://docs.gitlab.com/update/upgrade/?tab=Docker#pre-upgrade-and-post-upgrade-checks 

    1 Check the general configuration:

    # With Docker
    docker exec -it <container-name> gitlab-rake gitlab:check | tee mylogs/check.250916.out

    2 Confirm that encrypted database values can be decrypted:

    # With Docker
    docker exec -it <container-name> gitlab-rake gitlab:doctor:secrets | tee mylogs/doctor_secrets.250916.out