在Debian上迁移GitLab数据库的步骤如下:
服务器环境信息:
在新服务器安装相同版本的GitLab:
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-16.2.4-ce.0.el7.x86_64.rpm
yum -y install gitlab-ce-16.2.4-ce.0.el7.x86_64.rpm
备份原GitLab数据:
gitlab.rb
和 gitlab-secrets.json
:scp /etc/gitlab/gitlab.rb root@192.168.2.200:/etc/gitlab/
scp /etc/gitlab/gitlab-secrets.json root@192.168.2.200:/etc/gitlab/
gitlab-rake gitlab:backup:create
mkdir -p /var/opt/gitlab/backups
scp /var/opt/gitlab/backups/1725431200_2024_09_04_16.2.4_gitlab_backup.tar root@192.168.2.200:/var/opt/gitlab/backups/
chmod 777 /var/opt/gitlab/backups/1725431200_2024_09_04_16.2.4_gitlab_backup.tar
还原GitLab数据:
gitlab-ctl stop nginx
gitlab-ctl stop puma
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-rake gitlab:backup:restore BACKUP=1725431200_2024_09_04_16.2.4
gitlab-secrets.json
文件:scp /etc/gitlab/gitlab-secrets.json root@192.168.2.200:/etc/gitlab/
gitlab-ctl restart
访问GitLab:
请注意,以上步骤可能因GitLab版本和服务器配置的不同而有所差异。在执行迁移之前,请确保详细阅读GitLab官方文档,并在测试环境中进行充分测试。