1.因业务需要,将原来服务器上的gitlab迁移到另一台服务器上。首先,确定原来的gitlab版本:145旧的服务器,146新服务器
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION ===>10.5.1
2.安装gitlab依赖:
yum install policycoreutils-python curl openssh-server ca-certificates postfix
3.下载gitlab:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
找到对应版本下载
4.rpm -ivh gitlab-ce-10.5.1-ce.0.el7.x86_64.rpm
gitlab-ctl reconfigure 初始化gitlab
5.下载安装gitlab汉化包:
项目地址为:https://gitlab.com/xhang/gitlab
我的gitlab版本为10.5.1
git clone https://gitlab.com/xhang/gitlab.git -b v10.5.1-zh
想要其他版本的gitlab:
git clone https://gitlab.com/xhang/gitlab.git -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 -y
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 10.5.1-zh.diff
修改默认gitlab端口:
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
vim /etc/gitlab/gitlab.rb :
external_url 'http://xxxxx.146'
重启gitlab: gitlab-ctl stop ==> gitlab-ctl start
5.145服务器创建gitlab备份:gitlab-rake gitlab:backup:create
6.进行145服务器gitlab备份路径将备份数据拷贝到146新服务器上
cd /var/opt/gitlab/backups
将备份数据放置到/var/opt/gitlab/backups
修改备份文件权限:chmod 777 1546916920_2019_01_08_10.5.1_gitlab_backup.tar
7.146新服务器恢复gitlab数据
停止gitlab数据服务
gitlab-ctl stop unicorn
gitlab-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 restart
9.每天自动备份gitlab,并只保留近7天备份
编辑备份脚本vim /var/opt/gitlab/gitbackup.sh
# !/bin/bash
gitlab-rake gitlab:backup:create CRON=1
将该脚本加入crontab中执行,每天凌晨1点备份 crontab -e:
0 1 * /var/opt/gitlab/gitbackup.sh &>/dev/null
vim /etc/gitlab/gitlab.rb
找到gitlab_rails['backup_keep_time'] = 604800取消注释,
gitlab-ctl reconfigure 重读配置并重启gitlab-ctl restart