gitlab迁移
- 了解机器的环境(操作系统,配置,网络等)
- 保持迁移时的一致性
- 迁移时保持操作系统一致性
- 迁移时gitlab版本一致性
- gitlab安装方式也要保持一致(安装时建议用清华镜像)
- 正式迁移前先预演
- gitlab备份与恢复(需要停机)
- gitlab迁移时问题处理(如:git project(非空的)界面不显示branches、files、commits等相关信息【需要清理redis缓存】)
备份恢复记录:
当前生产机器
停止gitlab服务:sudo gitlab-ctl stop
预期结果,访问出现:503 Service Unavailable
生成备份文件 (用时约30min,8.7G)
sudo gitlab-rake gitlab:backup:create
备份文件存放目录:/var/opt/gitlab/backup
scp备份到新机器
sudo scp 1462837514_gitlab_backup.tar root@x.x.x.x:/var/opt/gitlab/backups
新机器
更改备份的用户组
chown -R git:git 1462837514_gitlab_backup.tar
使用恢复命令进行恢复
# Stop processes that are connected to the database
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
# Verify
sudo gitlab-ctl status
# This command will overwrite the contents of your GitLab database!
sudo gitlab-rake gitlab:backup:restore BACKUP=1462837514
# Start GitLab
sudo gitlab-ctl start
# Check GitLab
sudo gitlab-rake gitlab:check SANITIZE=true
对gitlab进行修复
Uploads directory setup correctly? ... no
Try fixing it:
sudo chown -R git /var/opt/gitlab/gitlab-rails/uploads
sudo find /var/opt/gitlab/gitlab-rails/uploads -type f -exec chmod 0644 {} ;
sudo find /var/opt/gitlab/gitlab-rails/uploads -type d -not -path /var/opt/gitlab/gitlab-rails/uploads -exec chmod 0700 {} ;
Repo base access is drwxrws---? ... no
Try fixing it:
sudo chmod -R ug rwX,o-rwx /var/opt/gitlab/git-data/repositories
sudo chmod -R ug-s /var/opt/gitlab/git-data/repositories
sudo find /var/opt/gitlab/git-data/repositories -type d -print0 | sudo xargs -0 chmod g s
清理redis缓存
sudo gitlab-rake cache:clear RAILS_ENV=production
其他
gitlab配置文件(建议从原来机器scp)
/etc/gitlab/gitlab.rb
/etc/gitlab/gitlab-sercrets.json
参考:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md
https://github.com/gitlabhq/gitlabhq/issues/4864
(adsbygoogle = window.adsbygoogle || []).push({});