Gitlab install & backup
gitlab Ubuntu 20.04 and 22.04
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
# skip this step and configure an external SMTP server after GitLab has been installed
sudo apt-get install -y postfix
# Add the GitLab package repository
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
# set up your DNS, and change https://gitlab.example.com to the URL at which you want to access your GitLab instance.
# Installation will automatically configure and start GitLab at that URL
sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ce=14.5.1-ce.0
sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee=14.5.1-ee.0
# List available versions: apt-cache madison gitlab-ee
# Specifiy version: sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee=16.2.3-ee.0
Running handlers:
Running handlers complete
Chef Infra Client finished, 568/1524 resources updated in 04 minutes 28 seconds
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
Thank you for installing GitLab!
GitLab should be available at http://git.example.com
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ171B?installation=omnibus&release=14-5
# Pin the version to limit auto-updates:
sudo apt-mark hold gitlab-ee
# Show what packages are held back:
sudo apt-mark showhold
# edit configuration
vim /etc/gitlab/gitlab.rb
sudo gitlab-ctl reconfigure
# Browse to the hostname and login
# Set up your communication preferences
gitlab docker-compose
gitlab:
image: 'gitlab/gitlab-ce:latest'
restart: always
container_name: gitlab
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- 80:80
- 443:443
- 22:22
volumes:
- $GITLAB_HOME/config:/etc/gitlab
- $GITLAB_HOME/logs:/var/log/gitlab
- $GITLAB_HOME/data:/var/opt/gitlab
shm_size: '256m'
# find root password
docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
gitlab backup
# You can only restore a backup to exactly the same version and type (CE or EE) of GitLab on which it was created
# Linux package (Omnibus)
sudo gitlab-backup create
# <backup-id>_gitlab_backup.tar
sudo cp 11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar /var/opt/gitlab/backups/
sudo chown git:git /var/opt/gitlab/backups/11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar
sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
# Verify
sudo gitlab-ctl status
# This command will overwrite the contents of your GitLab database!
# NOTE: "_gitlab_backup.tar" is omitted from the name
sudo gitlab-backup restore BACKUP=11493107454_2018_04_25_10.6.4-ce
sudo gitlab-ctl restart
sudo gitlab-rake gitlab:check SANITIZE=true
sudo gitlab-rake gitlab:doctor:secrets
sudo gitlab-rake gitlab:artifacts:check
sudo gitlab-rake gitlab:lfs:check
sudo gitlab-rake gitlab:uploads:check
# change root password
sudo gitlab-rake "gitlab:password:reset[root]"
scripts
# view env info
sudo gitlab-rake gitlab:env:info
# view status
sudo gitlab-rake gitlab:check
#
sudo gitlab-rake db:migrate:status
#
sudo gitlab-ctl restart
# reload nginx
sudo gitlab-ctl hup nginx
gitlab-ctl --help
# Starting a Rails console session
sudo gitlab-rails console
# Using the PostgreSQL database service
sudo gitlab-psql
gitlabhq_production=# update Projects set runners_token_encrypted = null where id = 226;
UPDATE 1
# view log
sudo tail -n 200 /var/log/gitlab/gitlab-rails/production.log
Gitlab Runner install
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
sudo apt-get install gitlab-runner
# To install a specific version of GitLab Runner:
apt-cache madison gitlab-runner
sudo apt-get install gitlab-runner=16.5.0
# APT pinning
cat <<EOF | sudo tee /etc/apt/preferences.d/pin-gitlab-runner.pref
Explanation: Prefer GitLab provided packages over the Debian native ones
Package: gitlab-runner
Pin: origin packages.gitlab.com
Pin-Priority: 1001
EOF
# update GitLab Runner, Simply execute to install latest version:
sudo apt-get update
sudo apt-get install gitlab-runner
Gitlab runner regist
sudo gitlab-runner register
# Enter your GitLab instance URL (also known as the gitlab-ci coordinator URL).
# Enter the token you obtained to register the runner.
# Enter a description for the runner. You can change this value later in the GitLab user interface.
# Enter the tags associated with the runner, separated by commas. You can change this value later in the GitLab user interface.
# Enter any optional maintenance note for the runner.
# Provide the runner executor. For most use cases, enter `docker`.
# If you entered `docker` as your executor, you are asked for the default image to be used for projects that do not define one in .gitlab-ci.yml
config.toml
sudo vim /etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0
log_level = "debug"
log_format = "text"
[session_server]
session_timeout = 1800
[[runners]]
name = "rajeshkumar"
url = "http://43.205.228.212/"
id = 3
token = "AKrp1HueGK1DxaHxjNmD"
token_obtained_at = 2022-09-06T06:40:14Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[[runners]]
name = "raju123"
url = "http://43.205.228.212/"
id = 16
token = "aZ9zvKntG8-PKsm8s1HN"
token_obtained_at = 2022-09-06T07:13:53Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[[runners]]
name = "gitlab-test"
url = "https://gitlab.com/"
id = 17373720
token = "sJp-fyfCvj-K1M-yysfj"
token_obtained_at = 2022-09-06T09:09:09Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[[runners]]
name = "docker"
url = "https://gitlab.com/"
id = 17388862
token = "RDoZpsR8XzyuipDHzYsz"
token_obtained_at = 2022-09-07T04:31:53Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "alpine"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
shm_size = 0
[[runners]]
name = "group"
url = "https://gitlab.com/"
id = 17389806
token = "ES9VZQ4eZx_yfEyxVeqm"
token_obtained_at = 2022-09-07T05:09:40Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[[runners]]
name = "linux-runner"
url = "https://gitlab.com/"
id = 17390444
token = "UHdwAw3MXnyf-C1NgwMR"
token_obtained_at = 2022-09-07T05:49:15Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[[runners]]
name = "docker-runner"
url = "https://gitlab.com/"
id = 17390576
token = "_nHBeXQVrwj8V-xxq899"
token_obtained_at = 2022-09-07T05:57:22Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "alpine"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
docker-compose
version: "3.6"
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
restart: always
container_name: gitlab
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.example.com'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- 1880:80
- 1443:443
- 10022:22
volumes:
- $GITLAB_HOME/config:/etc/gitlab
- $GITLAB_HOME/logs:/var/log/gitlab
- $GITLAB_HOME/data:/var/opt/gitlab
shm_size: '256m'