下面按常见场景给你一个“迁移到 Debian 上的 GitLab”的实用指南。先明确你要的是哪一种迁移:
你现在的 GitLab 可能是:
下面以 最常见:从旧 GitLab 迁移到 Debian 自建 GitLab 为例。
sudo apt update
sudo apt install -y curl openssh-server ca-certificates tzdata perl
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ce
安装完成后:
sudo gitlab-ctl reconfigure
访问:
http://服务器IP
首次登录用 root,密码在:
cat /etc/gitlab/initial_root_password
适用于:同版本或大版本升级迁移
sudo gitlab-rake gitlab:backup:create
生成文件:
/var/opt/gitlab/backups/xxxxx_gitlab_backup.tar
scp old_server:/var/opt/gitlab/backups/*.tar \
/var/opt/gitlab/backups/
sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
sudo gitlab-rake gitlab:backup:restore BACKUP=时间戳
sudo gitlab-ctl restart
⚠️ 注意:
/etc/gitlab/gitlab.rb 需手动迁移适合只迁代码 + issue:
旧 GitLab:
项目 → Settings → General → Export project
新 Debian GitLab:
New project → Import project → GitLab export
只迁代码:
git clone --mirror git@old.gitlab.com:group/project.git
cd project.git
git push --mirror git@new.gitlab.com:group/project.git
从旧服务器复制:
/etc/gitlab/gitlab.rb
到新 Debian 服务器,然后:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
free -h # 看内存
在 gitlab.rb:
gitlab_rails['smtp_enable'] = true
apt update
apt install gitlab-ce
你可以告诉我:
我可以直接给你一步步命令版方案。