avatar
童琦杰
向死而生
githubmusic
2021-06-12编辑

Ubuntu下Gitlab安装、备份、恢复

安装

bash
sudo dpkg -i gitlab-ce_9.2.5-ce.0_amd64.deb
sudo gitlab-ctl reconfigure

备份

bash
sudo gitlab-rake gitlab:backup:create

默认备份文件位置: /var/opt/gitlab/backups

备份配置文件及密匙: /etc/gitlab/gitlab.rb/etc/gitlab/gitlab-secrets.json

恢复

bash
sudo cp gitlab.rb /etc/gitlab/gitlab.rb
sudo cp gitlab-secrets.json /etc/gitlab/gitlab-secrets.json
sudo cp 1622265010_2021_05_29_9.2.5_gitlab_backup.tar /var/opt/gitlab/backups/
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl status
sudo gitlab-rake gitlab:backup:restore BACKUP=1622265010_2021_05_29_9.2.5
sudo gitlab-ctl start
sudo gitlab-rake gitlab:check SANITIZE=true

配置HTTPS证书

修改Gitlab配置文件

/etc/gitlab/gitlab.rb
external_url '[https://domain]'
nginx['redirect_http_to_https']=true
nginx['ssl_certificate'] = "[path_of_certificate_file]"
nginx['ssl_certificate_key'] = "[path_of_certificate_private_key]"

更新配置

bash
sudo gitlab-ctl reconfigure

修改nginx配置文件

/var/opt/gitlab/nginx/conf/gitlab-http.conf
server_name [https://domain];
ssl on;
ssl_certificate [path_of_certificate_file];
ssl_certificate_key [path_of_certificate_private_key];

重启Gitlab服务

bash
sudo gitlab-ctl restart