gitlab

gitlab

安装

~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-10.2.0-ce.0.el6.x86_64.rpm
安装依赖
~]# yum install policycoreutils-python -y
~]# rpm -ivh gitlab-ce-10.2.0-ce.0.el6.x86_64.rpm
初始化gitlab 并启动
~]# gitlab-ctl reconfigure

当git的服务器地址发生改变时,配置文件中就需要做如下修改
一:

~]# vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: localhost         >> 这里改为主机的IP即可
    port: 80
    https: false
~]# gitlab-ctl restart      //重启即可

二:

~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.60.184'      >>此处修改为主机Ip即可

~]# gitlab-ctl restart


##查看gitlab版本信息
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

迁移

当只是迁移一个项目时,可直接clone出来并push上至新的gitlab即可。但是当需要把整个gitlab中的的所有项目做迁移时,就需要将gitlab的整个项目备份出来并导入至新的环境中即可。

注:新gitlab服务器与原服务器gitlab版本必须一样,原因应该是由于gitlab自身的兼容性问题,高版本的gitlab无法恢复低版本备份的数据。(版本差异没有测试过,不知道可不可以。需要自行测试)


还好gitlab非常贴心,已经有备份项目的命令可供使用。
1. 备份

~]# gitlab-rake gitlab:backup:create RAILS_ENV=production
 * android/DesktopRobot.wiki ...  [SKIPPED]
done
Dumping uploads ... 
done
Dumping builds ... 
done
Dumping artifacts ... 
done
Dumping pages ... 
done
Dumping lfs objects ... 
done
Dumping container registry images ... 
[DISABLED]
Creating backup archive: 1532621181_2018_07_26_10.2.0_gitlab_backup.tar ... done
Uploading backup archive to remote storage  ... skipped
....

~]# ll /var/opt/gitlab/backups/
-rw------- 1 git git 2130063360 Jul 26 09:07 1532621181_2018_07_26_10.2.0_gitlab_backup.tar

注:备份后的文件存放于/var/opt/gitlab/backups/目录下,文件名如1532621181_2018_07_26_10.2.0_gitlab_backup.tar

2.传输
将备份出来的包传入新服务器相同的备份目录内/var/opt/gitlab/backups/下

3. 导入

~]# gitlab-rake gitlab:backup:restore RAILS_ENV=production   BACKUP=1532621181_2018_07_26_10.2.0
Unpacking backup ... tar: repositories/robot/Robot.bundle: time stamp 2018-07-27 00:05:02 is 27977.161072992 s in the future
tar: repositories/robot/RobotQuestion.bundle: time stamp 2018-07-27 00:04:15 is 27930.115117073 s in the future
...
done
done
原文地址:https://www.cnblogs.com/dance-walter/p/9372555.html