以下是在Linux上迁移GitLab的步骤:
备份数据
使用命令 sudo gitlab-rake gitlab:backup:create
备份数据,文件默认存放在 /var/opt/gitlab/backups/
目录。
可选:若需迁移数据库,可备份PostgreSQL数据:
sudo -u postgres pg_dump -d gitlabhq_production > gitlab-backup.sql
准备新服务器
yum install policycoreutils openssh-server postfix
systemctl enable sshd postfix
传输数据
scp
或其他工具复制到新服务器的 /var/opt/gitlab/backups/
目录。rsync
同步:rsync -avz /var/opt/gitlab/{repositories,config,shared}/ user@new-server:/var/opt/gitlab/
恢复数据与配置
sudo gitlab-rake gitlab:backup:restore BACKUP=备份文件名
。/etc/gitlab/gitlab.rb
,更新域名、IP等参数。重启服务与验证
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start
访问新服务器GitLab,检查项目、用户权限等是否正常。
注意事项:
参考来源: