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
-
install GitLab 6.9.2 (gitlab_6.9.2-omnibus.2-1_amd64.deb)
Download and install GitLab | GitLab
sudo wget https://downloads-packages.s3.amazonaws.com/ubuntu-12.04/gitlab_6.9.2-omnibus.2-1_amd64.deb
sudo chmod 777 gitlab_6.9.2-omnibus.2-1_amd64.deb
sudo dpkg -i gitlab_6.9.2-omnibus.2-1_amd64.deb
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart -
copy backup in home folder
e.g. scp gitlab_backup.tar root@hostname_server_or_IP:/home/homefolder -
restore backup from the old server: move backup file from /home directory to /var/opt/gitlab/backups
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
- after the backup was restored restart gitlab
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
Importing an external Git repository using the command line - GitHub Docs
doc/raketasks/backup_restore.md · master · GitLab.org / GitLab CI · GitLab
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!