gitlab安装、备份、恢复

gitlab安装、备份、恢复

gitlab安装

下载gitlab源

curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | bash

安装最新版本gitlba

yum -y install gitlab-ce 

安装对应某一版本gitlab

yum -y install gitlab-ce-xx.xx.xx

安装成功后重新配置应用程序

gitlab-ctl reconfigure

状态管理

gitlab-ctl start/stop/restart/status

gitlab默认使用nginx做为web界面

netstat -antup | grep :80

查看gitlab版本

cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

根据自己需求,可修改配置文件,修改一些参数

vim /etc/gitlab/gitlab.rb
13 external_url 'http://gitlab.example.com'		   #修改访问域名

# 修改访问端口
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
34 server {
35   listen *:80;	 # 改为对应端口
38   server_name gitlab.example.com;   	# 上面域名改了,这里也要改
}

修改完成后还要重新加载配置

gitlab-ctl reconfigure
gitlab-ctl restart 

到此gitlab安装完成,浏览器访问
注意,访问web界面需要3G以上的内存,否则会出现502报错,要不就是很卡,建议安装gitlab的机子最少3G内存以上。

gitlab代码备份

命令

gitlab-rake gitlab:backup:create

默认备份到/var/opt/gitlab/backups目录下,可在/etc/gitlab/gitlab.rb配置文件中修改

写入定时任务,按自己需求定时间

crontab -e
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1

修改配置文件,定义gitlab代码备份路径为/data/backups/gitlab,代码保留时间为7天

vim /etc/gitlab/gitlab.rb
343 gitlab_rails['backup_path'] = "/data/backups/gitlab"   #代码备份目录
351 gitlab_rails['backup_keep_time'] = 604800              #备份的代码保留时间,单位为秒

gitlab代码恢复

如果是把代码恢复到别的机器,注意新机器的gitlab版本一定要跟老gitlab版本一样,要不恢复出错。
把备份出的gitlab代码拷贝到新gitlab服务器的代码备份目录中,如果没有更改备份路径的话也就是/var/opt/gitlab/backups目录中

恢复代码前要先停止相关数据库连接服务

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq

备份的gitlab代码都会带有一个编号,根据编号恢复代码

gitlab-rake gitlab:backup:restore BACKUP=1565402545_2019_08_10_12.0.3

要点时间,还得输入yes答复。

重启gitlab

gitlab-ctl restart

重新访问gitlab界面,使用备份gitlab代码中的用户名密码登陆。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值