本文Gitlab的安装为主机方式, 获取其余安装方式请点击https://git.lug.ustc.edu.cn/h...html
[gitlab-ce] name=Gitlab CE Repository baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck=0 enabled=1 EOF
$ yum makecache $ yum install gitlab-ce
配置文件/etc/gitlab/gitlab.rb注: 你可根据注释修改配置文件,通常修改以下
external_url 'http://gitlab.xxxxxx.com' #改域名,修改为你本身的域名,若是你用的https,改为https://gitlab.xxxxxx.comnginx
$ gitlab-ctl reconfigure ## 使配置生效 $ gitlab-ctl status ## 确认服务状态
先打开/etc/gitlab/gitlab.rb配置文件,查看一个和备份相关的配置项:
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
该项定义了默认备份出文件的路径,能够经过修改该配置,并执行 gitlab-ctl reconfigure 或者 gitlab-ctl restart 重启服务生效。git
备份执行一条命令就搞定:/opt/gitlab/bin/gitlab-rake gitlab:backup:create ,也能够加到crontab中定时执行:web
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create
能够到 /var/opt/gitlab/backups找到备份包,解压查看,会发现备份的仍是比较全面的,数据库、repositories、build、upload等分类仍是比较清晰的。redis
天天执行备份,确定有目录被爆满的风险,咱们能够立马想到的能够经过find 查找必定的时间前的文件,配合rm进行删除。不过不须要这么麻烦,gitlab-ce自身集成的有自动删除配置。
一样打开/etc/gitlab/gitlab.rb配置文件,能够找到以下配置:
gitlab_rails['backup_keep_time'] = 604800这里是设置备份保留7天(7360024=604800),秒为单位,若是想增大或减少,能够直接在该处配置,并经过gitlab-ctl restart 重启服务生效。sql
1. 恢复前须要先停掉数据链接服务:数据库
gitlab-ctl stop unicorn gitlab-ctl stop sidekiq
若是是台空主机,没有任何操做,理论上不停这两个服务也能够。停这两个服务是为了保证数据一致性。服务器
2. 迁移数据
若是你没修改过默认备份目录的话,将老服务器/var/opt/gitlab/backups目录下的备份文件拷贝到新服务器上的/var/opt/gitlab/backups架构
[root@localhost gitlab]# scp 1530773117_2018_07_05_gitlab_backup.tar 10.0.3.111:/var/opt/gitlab/backups/ ## 600权限是无权恢复的。--- 这里改为了777 [root@localhost backups]# pwd /var/opt/gitlab/backups [root@localhost backups]# chmod 777 1530773117_2018_07_05_gitlab_backup.tar [root@localhost backups]# ll total 17328900 -rwxrwxrwx 1 git git 17744793600 Jul 5 14:47 1530773117_2018_07_05_gitlab_backup.tar
执行下面的命令进行恢复:后面再输入两次yes就完成恢复了。socket
gitlab-rake gitlab:backup:restore BACKUP=1530773117_2018_07_05_gitlab_backup.tar
PS:根据版本不一样恢复时可能有点小区别
# 默认的log主目录为 /var/log/gitlab/ # 检查redis的日志 sudo gitlab-ctl tail redis # 检查postgresql的日志 sudo gitlab-ctl tail postgresql # 检查gitlab-workhorse的日志 sudo gitlab-ctl tail gitlab-workhorse # 检查logrotate的日志 sudo gitlab-ctl tail logrotate # 检查nginx的日志 sudo gitlab-ctl tail nginx # 检查sidekiq的日志 sudo gitlab-ctl tail sidekiq # 检查unicorn的日志 sudo gitlab-ctl tail unicorn sudo gitlab-ctl status //检查所依赖的服务是否运行 sudo gitlab-ctl tail //检查gitlab所依赖的服务是否在运行时出错 sudo gitlab-rake gitlab:check //检查的配置是否正确,若是有错误,请根据提示解决它
error: proxyRoundTripper: GET "/" failed with: "dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory"
缘由:unicorn 没有正常启动
解决:查看unicorn的日志, /var/log/gitlab/unicorn/*.log, 通常为端口冲突或是权限问题。依赖相应的日志,但愿你能够很好的解决,enjoy it.