gitlab网上迁移文章很多,自己迁移的时候遇到很多坑,此处分析给各位
环境准备:
gitlab版本:9.1.2
主要参考文章:
https://blog.csdn.net/ouyang_peng/article/details/77334215
https://blog.csdn.net/heivy/article/details/53034632
https://www.cnblogs.com/kevingrace/p/7821529.html
https://www.cnblogs.com/wenwei-blog/p/6362829.html
https://www.cnblogs.com/straycats/p/7672692.html(推荐:远程定时备份有效)
备份:gitlab-rake gitlab:backup:create RAILS_ENV=production
备份文件在此目录下:/var/opt/gitlab/backups
恢复:gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1524129806_2018_04_19(备份文件为:1524129806_2018_04_19_gitlab_backup.tar,BACKUP不用加“_gitlab_backup.tar”部分)
查询日志:tail -f /var/log/gitlab/redis/current
定时脚本:auto_backup_to_remote.sh
手动运行脚本:./auto_backup_to_remote.sh
添加定时任务:
crontab -e //
0 2 * * * /root/auto_backup_to_remote.sh -D 1
chmod 774 /root/auto_backup_to_remote.sh //给脚本授权
systemctl restart crond
遇到的各种坑(部分解决):
(1)、迁移过程中恢复git仓库时出现如下问题:
技术研发部 > gitlab备份迁移 > image2018-4-19 19:41:24.png
此种项目无法做pull/push操作,具体原因不清楚,网上没有可靠的解决办法,最后是删除项目重建;
(2)、无法远程传递备份文件192.168.64.2无法scp传递文档到192.168.70.91但逆向过程可以;
问题已解决,问题原因:/root/.ssh/authorized_keys文件权限问题
ls -l authorized_keys//查看其权限,确认只有读的权限
chmod 600 authorized_keys//修改为读写权限
(3)、备份恢复时不要关停gitlab,因为备份恢复时包含恢复缓存信息,停掉gitlab会关停相关redis服务;
(4)、部分人员登录gitlab报:403,处理方式:https://blog.csdn.net/qq_14989227/article/details/78395768