在Debian上升级GitLab的流程大致可以分为以下几个步骤:
更新系统:
sudo apt update
sudo apt upgrade
安装必要的依赖包:
sudo apt install -y curl openssh-server ca-certificates tzdata perl
添加GitLab官方仓库:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
安装GitLab CE:
sudo apt install gitlab-ce
在安装过程中,系统会提示你设置管理员密码和域名,请按照提示进行操作。
重新配置GitLab:
sudo gitlab-ctl reconfigure
设置防火墙规则(如果需要):
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
备份旧GitLab数据:
gitlab-rake gitlab:backup:create
备份文件通常位于 /var/opt/gitlab/backups
目录下。
在新服务器上安装相同版本的GitLab:
查看原GitLab版本号:
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
在新服务器上安装相同版本的GitLab,例如:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-16.2.4-ce.0.el7.x86_64.rpmyum -y install gitlab-ce-16.2.4-ce.0.el7.x86_64.rpm
备份原GitLab数据:
scp /etc/gitlab/gitlab.rb root@new_server_ip:/etc/gitlab/
scp /etc/gitlab/gitlab-secrets.json root@new_server_ip:/etc/gitlab/
传输备份到新服务器:
scp /var/opt/gitlab/backups/1725431200_2024_09_04_16.2.4_gitlab_backup.tar root@new_server_ip:/var/opt/gitlab/backups/
还原GitLab数据:
停止GitLab服务:
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl stop puma
替换 gitlab-secrets.json
文件:
scp /etc/gitlab/gitlab-secrets.json root@new_server_ip:/etc/gitlab/
重启GitLab:
gitlab-ctl restart
访问GitLab:
在浏览器中输入新服务器的IP地址,完成GitLab恢复。
请注意,以上步骤可能因GitLab版本和服务器配置的不同而有所差异。在执行迁移之前,请确保详细阅读GitLab官方文档,并在测试环境中进行充分测试。