本文共 1671 字,大约阅读时间需要 5 分钟。
1.因业务需要,将原来服务器上的gitlab迁移到另一台服务器上。首先,确定原来的gitlab版本:145旧的服务器,146新服务器
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION ===>10.5.12.安装gitlab依赖:yum install policycoreutils-python curl openssh-server ca-certificates postfix3.下载gitlab:找到对应版本下载4.rpm -ivh gitlab-ce-10.5.1-ce.0.el7.x86_64.rpmgitlab-ctl reconfigure 初始化gitlab5.下载安装gitlab汉化包:项目地址为:我的gitlab版本为10.5.1git clone -b v10.5.1-zh想要其他版本的gitlab:git clone -b vX.X.X-zh即可比较源包与汉化包并导出到/下git diff v10.5.1 v10.5.1-zh >/v10.5.1-zh.diff将v10.5.1-zh.diff作为补丁更新到gitlab中:yum install patch -ypatch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 10.5.1-zh.diff修改默认gitlab端口:vim /var/opt/gitlab/nginx/conf/gitlab-http.confvim /etc/gitlab/gitlab.rb :external_url ''重启gitlab: gitlab-ctl stop ==> gitlab-ctl start5.145服务器创建gitlab备份:gitlab-rake gitlab:backup:create6.进行145服务器gitlab备份路径将备份数据拷贝到146新服务器上cd /var/opt/gitlab/backups将备份数据放置到/var/opt/gitlab/backups修改备份文件权限:chmod 777 1546916920_2019_01_08_10.5.1_gitlab_backup.tar7.146新服务器恢复gitlab数据停止gitlab数据服务gitlab-ctl stop unicorngitlab-ctl stop sidekiq进入/var/opt/gitlab/backups 选择git备份文件号进行恢复gitlab-rake gitlab:backup:restore BACKUP=1546916920_2019_01_08_10.5.1恢复数据迁移完成8.修改gitlab默认备份路径:vim /etc/gitlab/gitlab.rb找到gitlab_rails['backup_path'] = "/data/gitBackup" 取消注释并修改为自定义备份路径gitlab-ctl reconfigure 重读配置并重启gitlab-ctl restart9.每天自动备份gitlab,并只保留近7天备份编辑备份脚本vim /var/opt/gitlab/gitbackup.sh# !/bin/bashgitlab-rake gitlab:backup:create CRON=1将该脚本加入crontab中执行,每天凌晨1点备份 crontab -e:0 1 * /var/opt/gitlab/gitbackup.sh &>/dev/nullvim /etc/gitlab/gitlab.rb找到gitlab_rails['backup_keep_time'] = 604800取消注释,gitlab-ctl reconfigure 重读配置并重启gitlab-ctl restart转载地址:http://cxyqa.baihongyu.com/