本文记录关于gitlab的备份问题。整个过程包含gitlab的安装,gitlab的备份,gitlab的恢复,另外添加了关于gitlab卸载的东西。我的环境是centos7.2。
- gitlab安装。
可参考这篇博客:Gitlab的安装。 具体的安装过程可总结为:
- 配置yum源;
vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=[https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/](https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/)
gpgcheck=0
enabled=1
- 更新缓存并安装
$ yum makecache
$ yum install gitlab-ce-9.4.3 //我是用的社区版9.4.3
- 配置启动
$ vim /etc/gitlab/gitlab.rb:
external_url 'http://localhost:90' //修改访问端口
$ gitlab-ctl reconfigure //修改配置文件后重启gitlab
$ gitlab-ctl start/stop/restart
- gitlab 备份和恢复
可参考这篇博客,Gitlab如何进行备份恢复与迁移。大致过程如下:
- 日常备份
$ gitlab-rake gitlab:backup:create
备份文件会保存在/var/opt/gitlab/backups下面。并且以_gitlab_backup.tar结尾。
- 拷贝相应的文件到需要恢复的机器的/var/opt/gitlab/backups目录下面。
- 恢复备份,其中有两个提示,都输入yes。包含账户信息都会被回复。
$ gitlab-rake gitlab:backup:restore BACKUP=1502357536_2017_08_10_9.4.3
其中遇到的问题:
在安装后执行reconfigure的时候有问题,提示8889端口正在被使用。那是因为卸载的时候不完全导致的。之前的程序还是运行。查出来kill掉就好。
- gitlab卸载
可能安装不成功会需要卸载。卸载需要先删除包,再停止gitlab,不然会一直重启。最后删除其他配置文件。
$ gitlab-ctl stop
$ rpm -e gitlab-ce
$ ps -ef|grep gitlab //杀掉runsvdir -P /opt/gitlab/service log
$ find / -name *gitlab*|xargs rm -rf