meta data for this page
  •  

This is an old revision of the document!


gitlab

Download location: https://packages.gitlab.com/gitlab/gitlab-ce
Archive versions: https://about.gitlab.com/downloads/archives/
Configure Gitlab's web server: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md

gitlab-ctl stop
gitlab-ctl start

Get installed version info

gitlab-rake gitlab:env:info
gitlab-ctl tail
gitlab-rake gitlab:app:check
gitlab-rake gitlab --tasks

Configuration

| /etc/gitlab/gitlab.rb
# will be started on :80 port
external_url "http://gitlab.example.com"
 
external_port "8888"
 
# will be started on :443 port
# by default certificate file same as hostname is required:
#   /etc/gitlab/ssl/gitlab.example.com.key
#   /etc/gitlab/ssl/gitlab.example.com.crt 
external_url "https://gitlab.example.com"
# redirect http to https
nginx['redirect_http_to_https'] = true
 
 
external_url "https://gitlab.example.com:2443"
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.key"
 
 
git_data_dir "/mnt/nas/git-data"
| /etc/gitlab/gitlab.rb
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_user_name'] = "username"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_domain'] = "gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
 
# If your SMTP server does not like the default 'From: gitlab@localhost' you
# can change the 'From' with this setting.
gitlab_rails['gitlab_email_from'] = 'gitlab.mydomain.org'
gitlab_rails['gitlab_email_display_name'] = 'MyDomain.org Gitlab'
gitlab_rails['gitlab_email_reply_to'] = 'username@gmail.com'
sudo gitlab-ctl reconfigure

Uninstall

# Stop gitlab and remove its supervision process
sudo gitlab-ctl uninstall
 
# Debian/Ubuntu
sudo dpkg -r gitlab

Making backup

  • block gitlab access (but leave maintenance web page)
    • gitlab-ctl deploy-page up
    • sudo gitlab-ctl stop unicorn
    • sudo gitlab-ctl stop sidekiq
  • Store configuration file manually (/etc/gitlab)
  • Trigger backup creation
    • gitlab-rake gitlab:backup:create
  • Start gitlab
    • gitlab-ctl start
    • gitlab-ctl deploy-page down

Make backup without repository

gitlab-rake gitlab:backup:create SKIP=repositories,uploads

For possible rake tasks to skip see into file /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake. For now it cane be: repositories,db,builds,uploads,artifacts,lfs

Automating backups

crontab -e

0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1

What is in backup

Backup file e.g.: 1462327272_gitlab_backup.tar is simple tar archive with example content:

|-- artifacts.tar.gz
|-- backup_information.yml
|-- builds.tar.gz
|-- db
|   `-- database.sql.gz
|-- lfs.tar.gz
|-- repositories
|   |-- group1
|   |   |-- http-server.bundle
|   |   |-- kernel.bundle
|   |-- group2
|   |   |-- buildroot.bundle
|   |   |-- linux-stable.bundle
|   |   |-- u-boot.bundle
|   |   `-- yocto.bundle
|   `-- user1
|       |-- buildroot.bundle
|       |-- linux-stable.bundle
|       |-- linux.bundle
|       |-- uboot.bundle
`-- uploads.tar.gz

Where .bundle filesa re simple tar archives of bare git repos.

Restoring backup

  • install exactly the same version from backup comes
  • install default gitlab package and make sure it is running
    • use /etc/gitlab from backup
    • run gitlab-ctl reconfigure
  • stop gitlab
    • sudo gitlab-ctl stop unicorn
    • sudo gitlab-ctl stop sidekiq
  • Restore backup
    • sudo gitlab-rake gitlab:backup:restore
    • OR sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186
  • Start GitLab
    • sudo gitlab-ctl start
  • Check GitLab
    • sudo gitlab-rake gitlab:check SANITIZE=true

Gitlab 7.4 empty repos issue

It is not possible to restore backup with empty repos.
Issue described here Restore issue with empty projects

gitlab:check errors

Projects have satellites? ... 
4/1 ... no
  Try fixing it:
  sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production
  If necessary, remove the tmp/repo_satellites directory ...
  ... and rerun the above command
  For more information see:
  doc/raketasks/maintenance.md 
  Please fix the error above and rerun the checks.
4/2 ... no
  • Create missing satellites
    • sudo gitlab-rake gitlab:satellites:create
    • sudo gitlab-ctl restart
    • sudo gitlab-rake cache:clear

Ubuntu Precise Gitlab 7.4 update

* Create LXC container with the same version as your working gitlab instance

  • Ubuntu LTS 12.04 Precise
  • Gitlab 7.4 (gitlab_7.4.3-omnibus.5.1.0.ci-1_amd64.deb)
  • copy /etc/gitlab form your working instance
  • execute gitlab-ctl reconfigure

* Update Gitlab to latest version

* Make backup

* Create LXC container with latest Ubuntu Xenial release

  • Follow official instructions to gitlab repos: Install a GitLab CE Omnibus package
    • edit /etc/apt/sources.list.d/gitlab_gitlab-ce.list and change distro to trusty
  • apt-get install gitlab-ce
  • gitlab-ctl reconfigure
  • get /etc/gitlab from previous LXC container
  • gitlab-ctl reconfigure to adapt directory structure to new configuration
  • get gitlab backup from previous LXC container

Issues

/var/opt/gitlab perm

FQDN issue

ERROR: External URL must include a FQDN

external_url = 'gitlab.thefallenphoenix.net'
external_url = 'gitlab.thefallenphoenix.net'

500 error webhooks

After pressing Test –> Push events, gitlab shows 500 ERROR page.

# gitlab-ctl tail

==> /var/log/gitlab/gitlab-rails/production.log <==

URI::InvalidURIError (URI::InvalidURIError):
  lib/gitlab/proxy_http_connection_adapter.rb:14:in `connection'
  app/services/web_hook_service.rb:73:in `make_request'
  app/services/web_hook_service.rb:26:in `execute'
  app/models/hooks/web_hook.rb:10:in `execute'
  app/services/test_hooks/base_service.rb:22:in `block in execute'
New security settigns was added. To allow remote network operations you should enable it in admin settings:
Outbound requests --> Allow requests to the local network from hooks and services
 
 
gitlab-rake check