1、gitlab的搭建
- 安装基础包
yum -y install curl policycoreutils openssh-server openssh-clients
- 启动sshd
systemctl enable sshd
systemctl start sshd
- 安装postfix
yum -y install postfix
systemctl enable postfix
systemctl start postfix
- 添加防火墙规则
firewall-cmd --permanent --add-service=http
systemctl reload firewalld
- 下载并安装软件包(软件包下载较慢)
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum install gitlab-ce
默认安装的是最新的gitlab-ce的包,如果需要特定的版本可以在官网去下载特定的版本
地址:
https://packages.gitlab.com/gitlab/gitlab-ce/
- 配置并启动gitlab
gitlab-ctl reconfigure
- 默认账户密码是
Username: root
Password: 5iveL!fe
2、 gitlab的备份
- 备份命令
gitlab-rake gitlab:backup:create
默然的备份目录为: /var/opt/gitlab/backups
备份文件名类似: 1393513186_gitlab_backup.tar
- 备份目录的修改
vi /etc/gitlab/gitlab.rb
gitlab_rails['backup_path'] = '/mnt/gitlab_backups'
3、gitlab数据的恢复或还原
提示:gitlab数据的恢复或者迁移成功的前提——两台服务器的gitlab的版本必须相同,若不相同则可能迁移或者恢复失败
- 将备份文件放在gitlab的默认备份目录
比如/var/opt/gitlab/backups下的1458217074_gitlab_backup.tar
- 设置自动备份
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create
- 恢复或者还原
停服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
恢复数据
gitlab-rake gitlab:backup:restore BACKUP=1458213020
BACKUP后面跟的是备份文件的时间戳,比如恢复备份文件1458217074_gitlab_backup.tar
gitlab-rake gitlab:backup:restore BACKUP=1458217074
- 回复完启动服务
gitlab-ctl start