From 27f2b2f0646c275d1d7ba9c1ca50a706297ffb44 Mon Sep 17 00:00:00 2001 From: stephan48 Date: Wed, 6 Mar 2024 01:01:34 +0100 Subject: [PATCH] --- posts/2024-03-06-restore-gitlab.mdwn | 97 ++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 posts/2024-03-06-restore-gitlab.mdwn diff --git a/posts/2024-03-06-restore-gitlab.mdwn b/posts/2024-03-06-restore-gitlab.mdwn new file mode 100644 index 0000000..1fb77da --- /dev/null +++ b/posts/2024-03-06-restore-gitlab.mdwn @@ -0,0 +1,97 @@ +This is opinionated for gitlab.xiph.org, the old VM is a buster, the new one a bookworm. + +- Get a VM +- Follow https://about.gitlab.com/install/#debian until just before installing gitlab itself +- Make sure to downgrade the apt sources list as needed if your OS is too new for the old gitlab version :/ +- Do apt update +- Install the gitlab version from the backup i.e. if the Backupfile is named "/var/opt/gitlab/backups/1687588575_2023_06_24_16.0.5_gitlab_backup.tar" you want 16.0.5-ce.0 +- Copy over the requesite file from /etc/gitlab/config_backup/gitlab_config_*2023_06_24* and extract to /etc/gitlab/ + +``` +tar -C / -xf gitlab_config_*2023_06_24*.tar +``` + +- Adapt config to new hostnames. +- Install acmetool and run: + +``` +acmetool want newhostname.newdomain.newtld +``` + +- Reconfigure gitlab + +``` +gitlab-ctl reconfigure +``` + +- Adapt acmetool config to work with the now running nginx(we needed the cert so nginx would start, so it could do the redirects *AAAAAAARRRGGHHH* before we could have acmetool place the files \o/): + +``` +# /var/lib/acme/conf/target +request: + challenge: + webroot-paths: + - /var/www/.well-known/acme-challenge + http-self-test: false +``` + +- Adapt cron for acmetool + +``` +# cat /etc/cron.d/acmetool +SHELL=/bin/sh +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin +MAILTO=root +6 23 * * * root SHELL=/bin/sh +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin +MAILTO=root +6 23 * * * root /usr/bin/acmetool --batch reconcile && gitlab-ctl restart +``` + +- Touch `/var/lib/acme/live/newhost.newdomain.newtld/revoked` to force acmetool to renew +- Run `/usr/bin/acmetool --batch reconcile && gitlab-ctl restart` +- Wait half an hour until your gitlab is back up, you now have a fresh instance +- Copy the backup and change perms + +``` +cp 1687588575_2023_06_24_16.0.5_gitlab_backup.tar /var/opt/gitlab/backups/ +chown git:git /var/opt/gitlab/backups/1687588575_2023_06_24_16.0.5_gitlab_backup.tar +``` + +- Stop processes + +``` +sudo gitlab-ctl stop puma +sudo gitlab-ctl stop sidekiq +``` + +- Verify + +``` +sudo gitlab-ctl status +``` + +- Perform the magic + +``` +gitlab-backup restore BACKUP=1687588575_2023_06_24_16.0.5 +``` + +- Start again and verify + +``` +gitlab-ctl status +gitlab-ctl start +``` + +- Wait.... +- The frontpage of your instance should now look the same as on the original +- Remember we just restored the database from an auto db backup, we have NO data! +- This means we need to cheat a bit more and now upgrade the instance to the same version as in "prod" - currently 16.9.1-ce.0 +- To do this we need to check Upgrade Paths \o/ - follow this https://docs.gitlab.com/ee/update/ +- To get from 16.0.5 to 16.9.1 we will need to do: 16.0.8->16.1.6->16.2.9->16.3.7->16.7.6->16.9.1 \o/ +- We will first tackle 16.0.8 + +``` +apt install gitlab-ce=16.0.8-ce.0 +``` -- 2.30.2