官方迁移文档
确认gitlab版本
gitlab网页上help里查看,或命令查看,我这里版本是13.3.5
1
| sudo docker exec gitlab cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
|
备份
1
2
3
4
5
6
7
| sudo docker exec gitlab gitlab-ctl stop puma
sudo docker exec gitlab gitlab-ctl stop sidekiq
sudo docker exec gitlab gitlab-ctl status
sudo docker exec gitlab gitlab-backup create
|
会在容器内下面位置生成备份文件,拷贝到新的gitlab服务器
/var/opt/gitlab/backups/1625145187_2021_07_01_13.3.5_gitlab_backup.tar
配置文件,拷贝到新的gitlab服务器 官方链接
/etc/gitlab/gitlab-secrets.json
/etc/gitlab/gitlab.rb # 可选
还原
官方跨版本升级
13.3.5 –> 13.12.5 –> 14.0.1
1
2
3
4
5
6
| sudo docker run --detach \
--name gitlab-13.3.5 \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:13.3.5-ce.0
|
1
2
| sudo docker exec gitlab-13.3.5 gitlab-ctl stop puma
sudo docker exec gitlab-13.3.5 gitlab-ctl stop sidekiq
|
1
2
3
4
5
6
7
8
9
10
| sudo cp 1625145187_2021_07_01_13.3.5_gitlab_backup.tar /srv/gitlab/data/backups/
sudo docker exec gitlab-13.3.5 bash -c 'chown git.git /var/opt/gitlab/backups/1625145187_2021_07_01_13.3.5_gitlab_backup.tar'
# 有交互,所以一定要加-it
sudo docker exec -it gitlab-13.3.5 gitlab-backup restore BACKUP=1625145187_2021_07_01_13.3.5
sudo cp /srv/gitlab/config/gitlab-secrets.json{,.bak}
sudo cp gitlab-secrets.json /srv/gitlab/config/
sudo docker exec gitlab-13.3.5 gitlab-ctl reconfigure
sudo docker exec gitlab-13.3.5 gitlab-ctl restart
sudo docker exec gitlab-13.3.5 gitlab-rake gitlab:check SANITIZE=true
|
1
2
3
4
5
6
7
8
9
| sudo docker stop gitlab-13.3.5
sudo docker rm -v gitlab-13.3.5
sudo docker run --detach \
--name gitlab-13.12.5 \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:13.12.5-ce.0
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| sudo docker stop gitlab-13.12.5
sudo docker rm -v gitlab-13.12.5
sudo docker run --detach \
--hostname gitlab.mkl.io \
--publish 880:80 --publish 22:22 \
--name gitlab-14.0.1 \
--restart always \
--env TZ='Asia/Shanghai' \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
--shm-size 256m \
gitlab/gitlab-ce:14.0.1-ce.0
|