docker deployment GitLab configure the machine to automatically backup, automatic cleaning

Docker deployment GitLab

Mirror pulling 1.gitlab

# gitlab-ce为稳定版本,后面不填写版本则默认pull最新latest版本
$ docker pull gitlab/gitlab-ce

2. Run gitlab Mirror

docker run -d  -p 4003:443 -p 4001:80 -p 4002:22 --name gitlab --restart always -v /home/gitlab/config:/etc/gitlab -v /home/gitlab/logs:/var/log/gitlab -v /home/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce

3. Configure
according to the above manner, gitlab container run no problem, but when you create a project on a gitlab, URL access address generated by the project is to generate the hostname of the container, which is the id of the container. As gitlab server, we need to access a URL address is fixed, so you need to configure gitlab.rb (host path: /home/gitlab/config/gitlab.rb).

# gitlab.rb文件内容默认全是注释
$ vim /home/gitlab/config/gitlab.rb
# 配置http协议所使用的访问地址,不能加端口,加端口无法访问,这里使用默认80
external_url 'http://39.104.91.250'

# 配置ssh协议所使用的访问地址和端口
gitlab_rails['gitlab_ssh_host'] = '39.104.91.250'
gitlab_rails['gitlab_shell_ssh_port'] = 4002 # 此端口是run时22端口映射的4002端口
# 重启gitlab容器
$ docker restart gitlab

At this address of the warehouse project had changed. If the address is not the default ssh port 22, it will add ssh: // protocol header
to open the browser and enter the ip: port number to access. Here is http://39.104.91.250:4001

Automatic Backup

1. Create a backup script files auto_backup.sh:

#! /bin/bash
docker exec gitlab gitlab-rake gitlab:backup:create

2. /etc/crontabTiming task profile:

0 2 * * * root /home/gitlab/data/backups/auto_backup.sh

0 2 * * *Day two in the morning

Automatic Backup Cleanup

1. Create a backup script files auto_delete.sh:

find /home/gitlab/data/backups/ -mtime +7 -type f -name "*.tar" -exec rm -rf {} \;

Find and delete / home / gitlab / data / backups / directory content modification time (mtime) 7 days ago tar files (-type f), and delete (rm -rf)

2. /etc/crontabTiming task profile:

* 22 * * 6 root /home/gitlab/data/backups/auto_delete.sh

* 22 * * 6Every Saturday night 22:00

Reference:
Under docker gitlab which installation
GitLab automatic backup, clean up backup and recovery
GitLab code for automatic backup docker deployed
to find the specified folder / delete the specified folder linux

Published 35 original articles · won praise 32 · views 90000 +

Guess you like

Origin blog.csdn.net/u012995888/article/details/97544362