我目前gitlab在物理机上,我要把它迁移到docker里面,然后再升级到新版。
目前版本:13.3.5
目的版本:14.0.2
升级路线:gitlab13.3.5–>gitlab13.8.8–>gitlab13.12.15–>gitlab14.0.12
数据迁移:
数据备份:
gitlab-rake gitlab:backup:create
cd /var/opt/gitlab/backup
备份位置:/var/opt/gitlab/backup
将tar包传到新的gitlab服务器
数据导入:
同一版本才能支持导入不然会提示版本报错:
docker-compose 安装gitlab-13.3.5
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ce:13.3.5-ce.0'
restart: always
hostname: 'gitlab.test.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.test.com' #自己的域名
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
- '10022:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
- '$GITLAB_HOME/backup:/var/opt/gitlab/backups/'
把证书拷贝到config/ssl目录下面:
gitlab.test.com.crt
gitlab.test.com.key
启动:
docker-compose -f docker-gitlab.yml up -d
进入到docker里面:
chown git.git /var/opt/gitlab/backups/*.tar
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
cd /var/opt/gitlab/backup/ #1666322778_2022_10_21_13.3.5_gitlab_backup.tar
gitlab-rake gitlab:backup:restore BACKUP=1666322778_2022_10_21_13.3.5
提示输入yes:
导入完成之后,将旧版/etc/gitlab/gitlab-secrets.json 文件拷贝放到新版下。
重新启动gitlab:gitlab-ctl restart
ldap接入:
把旧版的gitlab.rb配置拷贝过来即可
升级
修改docker-gitlab.yml 文件镜像版本
image: ‘gitlab/gitlab-ce:13.8.8-ce.0’
…
image: ‘gitlab/gitlab-ce:14.0.12-ce.0’
测试runner,ldap,webook等是否和旧版一致