From 418dff5545adbbf9551f56f5b190e77e6e6355cd Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Wed, 15 Jan 2025 15:56:18 +0100 Subject: [PATCH] gitlab stuff --- content/content/HowTos/gitlab-backup.md | 61 +++++++++++++++++++ .../content/HowTos/gitlab-change-baseurl.md | 23 +++++++ content/content/HowTos/gitlab-upgrades.md | 24 ++++++++ 3 files changed, 108 insertions(+) create mode 100644 content/content/HowTos/gitlab-backup.md create mode 100644 content/content/HowTos/gitlab-change-baseurl.md create mode 100644 content/content/HowTos/gitlab-upgrades.md diff --git a/content/content/HowTos/gitlab-backup.md b/content/content/HowTos/gitlab-backup.md new file mode 100644 index 0000000..5792ad1 --- /dev/null +++ b/content/content/HowTos/gitlab-backup.md @@ -0,0 +1,61 @@ +--- +title: "Gitlab Backup and Restore" +--- + +## Backup +Find the backup directory: +``` +grep backup_path /etc/gitlab/gitlab.rb +``` + +Issue backup: +``` +sudo gitlab-backup create +``` + +Transfer backup using scp to destination machine. + +Backup configuration and secrets: +``` +sudp cp /etc/gitlab/gitlab-secrets.json /backuppath/ +sudo cp /etc/gitlab/gitlab.rb /backuppath/ +``` + +## Restore + +See also here: [https://docs.gitlab.com/ee/administration/backup_restore/restore_gitlab.html](https://docs.gitlab.com/ee/administration/backup_restore/restore_gitlab.html) + +*DO NOT OVERWRITE THE CONFIGURATION ON THE DESTINATION MACHINE. COMPARE IT AND CONSIDER AND EVALUATE EACH DIFFERENCE* + +Stop processes of GitLab connecting to the database: +``` +gitlab-ctl stop puma +gitlab-ctl stop sidekiq +# check +gitlab-ctl status +``` +Do not stop the whole system since the restore tool has to connect to the database which would also stop in that case. + + + +Issue restore. Run this command in a screen session. It is running quite long and requires manual intervention in between. + +``` +sudo gitlab-backup restore BACKUP=... +``` +Use the datecode and the version tag of the backup created above. + +Remember secrets and configuration. Do not overwrite configuration, see above. + +Reconfigure the instance: +``` +sudo gitlab-ctl reconfigure +``` + +Start the instance: +``` +sudo gitlab-ctl start +``` + + + diff --git a/content/content/HowTos/gitlab-change-baseurl.md b/content/content/HowTos/gitlab-change-baseurl.md new file mode 100644 index 0000000..954fce3 --- /dev/null +++ b/content/content/HowTos/gitlab-change-baseurl.md @@ -0,0 +1,23 @@ +--- +title: "Gitlab Change BaseURL in Database" +--- + +## Change URL + +After a migration changing the base url in the configuration is not enough. It must also be changed in the database. + +* Adjust the variable `external_url` in the file `/etc/gitlab/gitlab.rb` and run `gitlab-ctl reconfigure` +* Adjust the canonical URL in the database: + ``` + gitlab-rails console + ApplicationSetting.current.update!(home_page_url: 'https://neue-url.example.com') + ApplicationSetting.current.update!(after_sign_out_path: 'https://neue-url.example.com') + ``` +* Clear the internal cache: + ``` + gitlab-rake cache:clear + ``` + + + + diff --git a/content/content/HowTos/gitlab-upgrades.md b/content/content/HowTos/gitlab-upgrades.md new file mode 100644 index 0000000..cd34d2a --- /dev/null +++ b/content/content/HowTos/gitlab-upgrades.md @@ -0,0 +1,24 @@ +--- +title: "Gitlab Upgrades" +--- + +## Upgrade of a GitLab instance + +When upgrading a Gitlab instance, strictly follow the defined upgrade path. Consider to snapshot the filesystem if possible after each step. + +Additional, after each step wait until all background migrations are completed before performing the next upgrade step. + + + * [Upgrade Paths](https://docs.gitlab.com/ee/update/index.html#upgrade-paths) + * [Upgrading to a specific version](https://docs.gitlab.com/ee/update/package/#upgrade-to-a-specific-version-using-the-official-repositories) + +To find the versions of a specific package in the Debian apt cache use + +``` + apt-cache madison gitlab-ce +``` +To upgrade to a specific version use +``` + apt install gitlab-ce= +``` +**Definitely observe the version specific upgrade instructions, especially background migrations!**