gitlab常用操作
【摘要】 安装
安装docker
准备docker-compose.yml文件
web:
image: 'gitlab/gitlab-ce:11.0.3-ce.0'
restart: always
hostname: 'gitlab.example.com'
environment: GITLAB_OMNIBUS_CONFIG: | external_url 'htt...
安装
准备docker-compose.yml文件
web:
image: 'gitlab/gitlab-ce:11.0.3-ce.0'
restart: always
hostname: 'gitlab.example.com'
environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://5.25.24.16:6100' gitlab_rails['gitlab_shell_ssh_port'] = 6101 gitlab_rails['gitlab_email_from'] = 'pro@szfangle.com' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.szfangle.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "pro@szfangle.com" gitlab_rails['smtp_password'] = "123456" gitlab_rails['smtp_domain'] = "smtp.szfangle.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false
ports: - '6100:6100' - '6101:22'
volumes: - '/srv/gitlab/config:/etc/gitlab' - '/srv/gitlab/logs:/var/log/gitlab' - '/srv/gitlab/data:/var/opt/gitlab'
- 启动
docker-compose up -d
手动备份
sudo gitlab-rake gitlab:backup:create
默认备份文件在目录/var/opt/gitlab/backups/
下
还原
假设备份文件包名为
1531608284_2018_07_15_11.0.3_gitlab_backup.tar
拷贝备份文件到
/var/opt/gitlab/backups/
目录下,如果是docker安装,可拷贝到挂在点上还原文件
export time_stamp=1531608284_2018_07_15_11.0.3
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
chown git:git ${time_stamp}_gitlab_backup.tar
sudo gitlab-ctl start
sudo gitlab-rake gitlab:check SANITIZE=true
sudo gitlab-rake gitlab:backup:restore BACKUP=${time_stamp}
如果是docker安装,可使用
docker exec -it xxxxxx bash
进入容器,执行相关命令;
升级gitlab
- 备份 (可选),备份好的数据保存在目录
/var/opt/gitlab/backups
下
sudo gitlab-rake gitlab:backup:create STRATEGY=copy
- 升级
sudo yum install -y gitlab-ce #社区版运行该命令
# sudo yum install -y gitlab-ee #企业版运行该命令
配置邮箱
这里邮箱是我们公司邮箱配置,更多配置说明见官网
vim /etc/gitlab/gitlab.rb
### GitLab email server settings
gitlab_rails['gitlab_email_from'] = 'pro@szfangle.com'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.szfangle.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "pro@szfangle.com"
gitlab_rails['smtp_password'] = "PASWORD"
gitlab_rails['smtp_domain'] = "smtp.szfangle.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
设置外网端口
- 修改配置文件
/etc/gitlab/gitlab.rb
修改如下:
# external_url "http://gitlab.example.com"
external_url 'http://10.200.80.255:8081'
nginx['listen_port'] = 8081
- 重置配置
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
自动备份
- 安装软件
apt-get -y install crontabs
- 准备文件 /var/opt/gitlab/auto_backup.sh
#!/bin/bash
cd /srv/
tar -czf gitlab_$(date +"%Y%m%d").tar.gz gitlab
find "/srv/" -name "*.tar.gz" -ctime +31 -type f -exec rm -rf {} \;
- chmod +x /var/opt/gitlab/auto_backup.sh
-
crontab -e
配置每周日1点备份
* 1 * * 0 /srv/backup.sh
文章来源: www.jianshu.com,作者:Nick_4438,版权归原作者所有,如需转载,请联系作者。
原文链接:www.jianshu.com/p/7261385db472
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)