Upgrade Gitlab 6.5.1 to latest version ''10.6.4"

To migrate an old version of gitlab to the latest may be a more difficult than you imagine, because between these versions are more then 100 versions of updates and a lot of services and dependencies need to be updated.

After a lot of time(like a month) spent for research and tests, I did it!
So I decided to make a documentation and share it with you because when I made researches a lot of people still have this issue.

To do this involve a lot o steps like: backups, restore, upgrades, installing new servers and so on…
So in my case Gitlab 6.5.1 (with PostgreSQL) was installed on Ubuntu 12.04 which is another impediment for us. To do this you need to install an intermediary server Ubuntu 14.04 and after migrate all to the latest version of Ubuntu 18.04 / GitLab 10.6.4

You need an intermediary Ubuntu server 14.04 because you need to install Gitlab 6.9.2 Omnibus, my actual Gitlab 6.5.1 on Ubuntu 12.04 is installed from source.
And another reason is because you can’t install gitlab 6.9.2 omnibus on the latest version of Ubuntu 18.04 because isn’t supported…

So let’s start:

1. GITLab 6.5 to 6.9.2
Upgrade gitlab 6.5.1 to 6.9.2 with GITLAB Upgrader (in my case Ubuntu 12.04)
GitLab Upgrader - ruby script that allows you easily upgrade GitLab to latest minor version. Ex. it can update your application from 6.4 to latest GitLab 6 version (like 6.5.1). You still need to create backup and manually restart GitLab but all other operations can be done by upgrade tool.

In my case Gitlab is running already on PostgreSQL!!!

• Stop server
sudo service gitlab stop
• Run gitlab upgrade tool
cd /home/git/gitlab
sudo -u git -H ruby script/upgrade.rb

it also supports -y option to avouid user input

sudo -u git -H ruby script/upgrade.rb -y

• Start application
sudo service gitlab start
sudo service nginx restart

  • backup command for gitlab installed from source:
    cd /home/git/gitlab
    sudo apt-get install -y rsync
    sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production

https://docs.gitlab.com/ee/raketasks/backup_restore.html

2. Install and configure an Ubuntu server 14.04 with Gitlab 6.9.2 Omnibus
Copy backup to intermediary server Ubuntu 14.04 with scp command

cd /var/opt/gitlab
sudo chmod 777 backups
sudo mv /home/homefolder/backupfile.tar /var/opt/gitlab/backups
run sudo gitlab-rake gitlab:backup:restore command

3. Upgrade GITLab 6.9.2 to latest version on Ubuntu 14.04 server

Like I said already between these version are more then 100 updates you must install step by step.

a. upgrade gitlab 6.9.2 to 7.10.4
sudo wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab-ce_7.10.4~omnibus-1_amd64.deb
sudo chmod 777 gitlab-ce_7.10.4~omnibus-1_amd64.deb
dpkg -i gitlab-ce_7.10.4~omnibus-1_amd64.deb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

b. upgrade gitlab 7.10.4 to 8.2
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_8.2.0-ce.0_amd64.deb/download.deb
sudo chmod 777 gitlab-ce_8.2.0-ce.0_amd64.deb
sudo dpkg -i gitlab-ce_8.2.0-ce.0_amd64.deb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

c. upgrade gitlab 8.2 to 8.11.0
sudo wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_8.11.0-ce.1_amd64.deb/download.deb
sudo chmod 777 gitlab-ce_8.11.0-ce.1_amd64.deb
sudo dpkg -i gitlab-ce_8.11.0-ce.1_amd64.deb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

d. upgrade gitlab 8.11.0 to 8.15.0
sudo wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_8.15.0-ce.0_amd64.deb/download.deb
sudo chmod 777 gitlab-ce_8.15.0-ce.0_amd64.deb
sudo dpkg -i gitlab-ce_8.15.0-ce.0_amd64.deb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

e. upgrade gitlab 8.15 to 9.5.8
sudo wget --content-disposition - https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_9.5.8-ce.0_amd64.deb/download.deb
chmod 777 gitlab-ce_9.5.8-ce.0_amd64.deb
sudo dpkg -i gitlab-ce_9.5.8-ce.0_amd64.deb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

f. upgrade gitlab 9.5.8 to 10.1.0
sudo wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_10.1.0-ce.0_amd64.deb/download.deb
sudo chmod 777 gitlab-ce_10.1.0-ce.0_amd64.deb
sudo dpkg -i gitlab-ce_10.1.0-ce.0_amd64.deb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

g. upgrade gitlab 10.1.0 to 10.6.4 (latest version)
sudo wget --content-disposition - https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_10.6.4-ce.0_amd64.deb/download.deb
sudo chmod 777 gitlab-ce_10.6.4-ce.0_amd64.deb
sudo dpkg -i gitlab-ce_10.6.4-ce.0_amd64.deb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

h. Make a backup for all gitlab projects
sudo apt-get install -y rsync
cd /var/opt/gitlab
sudo gitlab-rake gitlab:backup:create

Copy gitlab backup to the desired server (Ubuntu 18.04)

4. Install a clean server and restore backup

Install and configure a clean Ubuntu 18.04 server with the same version of Gitlab, in my case GitLab 10.6.4

sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates
sudo apt-get install -y postfix
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL=“http://gitlab.example.com” apt-get install gitlab-ce
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

These commands will bring to you always the latest version of GitLab! If you need expressly 10.6.4 version you must install like the other versions with dpkg -i command.

After the backup is copied to server is time to restore the backup:

move backup file from home folder to /var/opt/gitlab/backups
cd /var/opt/gitlab
sudo chmod 777 backups
mv /home/gitlabbackup.tar /var/opt/gitlab/backups
sudo chmod 777 backupfile.tar
run sudo gitlab-rake gitlab:backup:restore command

after the backup was restored restart gitlab
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

5. Activate LDAP service
Activate LDAP service if you want to be integrated with your local AD.

  • edit gitlab.rb on /etc/gitlab/gitlab.rb
    sudo gitlab-ctl reconfigure
    sudo gitlab-ctl restart

6. Activate HTTPS protocol if you need it with let’s encrypt (is free).

Make some tests!!

Hope this how to guide will help you!!!

In my case this was the only option that I was able to migrate to the old version of Gitlab installed from source on Ubuntu 12.04.

Enjoy!

2 Likes

Hi

Thanks for the guide. I install gitlab-ce on Debian, CentOS and Ubuntu Server LTS boxes.

I normally install GitLab with the Omnibus package and perform patch updates on a monthly basis. When for some reason I lag to apply the patches (happened twice last year because other things were more relevant for management), I catched up with the following:

First, list the installed version with apt and check where you are. I understand you were in 6.5.1 before gitlab-ce omnibus versions were available (gitlab-ce/jessie 7.10.1~omnibus.1-1 amd64).

# apt list --installed gitlab-ce
gitlab-ce/jessie,now 10.1.1-ce.0 amd64 [installed,upgradable to: 10.7.3-ce.0]

Once apt shows the status for our gitlab-ce package. I check all the available versions of the omnibus in order to make an upgrade strategy.

# apt list --all-versions gitlab-ce | egrep 'installed|upgradable'
gitlab-ce/jessie 10.7.3-ce.0 amd64 [upgradable from: 10.7.1-ce.0]
gitlab-ce/jessie,now 10.7.1-ce.0 amd64 [installed,upgradable to: 10.7.3-ce.0]

I always set up a maintenance window and take a VM snapshot before applying any updates, so rollback is not an issue here.

My update strategy hops from minor releases by performing small upgrades (more or less in the same way as you did):

  1. Check all the available versions
  2. Use aptitude to jump from current version X.Y.M to X.Y.Z, where Z is the max revision for that minor version.
  • In my case from 10.1.1 to 10.1.7
# aptitude --download-only --assume-yes safe-upgrade gitlab-ce=10.1.7-ce.0
# aptitude --show-why--assume-yes safe-upgrade gitlab-ce=10.1.7-ce.0
# aptitude autoclean
# aptitude clean
  1. After that, jump from X.Y.Z to X.A.0, where A=Y+1
  • In my case from 10.1.7 to 10.2.0
# aptitude --download-only --assume-yes safe-upgrade gitlab-ce=10.2.0-ce.0
# aptitude --show-why--assume-yes safe-upgrade gitlab-ce=10.2.0-ce.0
# aptitude autoclean
# aptitude clean
  1. Upgrade from X.A.0 to X.A.Z, where Z is the max revision for that minor version.
# aptitude --download-only --assume-yes safe-upgrade gitlab-ce=10.2.8-ce.0
# aptitude --show-why--assume-yes safe-upgrade gitlab-ce=10.2.8-ce.0
# aptitude autoclean
# aptitude clean
  1. Repeat from 3 until you reach the latest version for omnibus.

Extra

I normally do something like this to check my upgrade path:

# apt list --all-versions gitlab-ce
Listing... Done
gitlab-ce/jessie 10.7.3-ce.0 amd64 [upgradable from: 10.1.1-ce.0]
	...
gitlab-ce/jessie 10.7.0-ce.0 amd64
--------
gitlab-ce/jessie 10.6.5-ce.0 amd64
	...
gitlab-ce/jessie 10.6.0-ce.0 amd64
--------
gitlab-ce/jessie 10.5.8-ce.0 amd64
	...
gitlab-ce/jessie 10.5.0-ce.0 amd64
--------
gitlab-ce/jessie 10.4.4-ce.0 amd64
	...
gitlab-ce/jessie 10.4.0-ce.0 amd64
--------
gitlab-ce/jessie 10.3.7-ce.0 amd64
	...
gitlab-ce/jessie 10.3.0-ce.0 amd64
--------
gitlab-ce/jessie 10.2.8-ce.0 amd64
	...
gitlab-ce/jessie 10.2.0-ce.0 amd64
--------
gitlab-ce/jessie 10.1.7-ce.0 amd64
	...
gitlab-ce/jessie,now 10.1.1-ce.0 amd64 [installed,upgradable to: 10.7.3-ce.0]
gitlab-ce/jessie 10.1.0-ce.0 amd64
--------
gitlab-ce/jessie 10.0.7-ce.0 amd64
	...
gitlab-ce/jessie 10.0.0-ce.0 amd64
--------

	...

gitlab-ce/jessie 7.10.1~omnibus.1-1 amd64
2 Likes

I realize this is an old post but I’ve been putting off migrating my own Gitlab installation for nearly 5 years. I tried a few years ago and failed but gave it another go this time. I started at exactly the same version on an Ubuntu 12.04 install.

In case others run into issues that I did while following this guide.

Make sure to leave the gitlab running or the updates will fail.

I ran into a problem with the upgrade script in the first step. I don’t recall how I got past it but I googled the errors until something finally worked. I think I had to do empty the cache or something at one point.

I ran into a problem with the transfer to the 14.04 box because I was on MySQL. So I had to convert to Postgres first. There is a tutorial at https://blog.baukunst.io/2015/05/migrate-gitlab-mysql-to-omnibus-postgres/ that you should follow to do this. It is important to do the reindexing or it won’t work.

I ran into a problem with the upgrade to 7.10.4. DB migrations fail on an index already existing. Just find the migration that failed and edit it directly removing the change. I had two back to back that failed. Manually run the migrations and you’ll be back to a working install.

I ran into an issue upgrade to 8.2.0. Skip this step because this upgrade path is broken. I found many forum posts all claiming the same. Instead replace this step with 8.2.1 which fixes the upgrade. If you’ve already upgraded to 8.2.0 it is too late so start over with a backup.

Going forward everything went flawlessly. Now I should be able to figure out how to get to the latest 12.X version following a similar path.

1 Like

Awesome, thanks for jumping in this thread, @rydan313!