Migrating gitlab to omnibus from source, debian to rpm, apache to nginx, and mysql to postgresql

I've had my own gitlab installation for a few years.  I built it long before it was easy to build and maintain.  Originally I installed gitlab from source, on ubuntu, using mysql and apache.  It's a real PITA to maintain given that omnibus installations are so much easier to maintain.  (omnibus is geek-speek for "all-in-one").  In this post I'll cover the steps I did to pull off upgrading this to omnibus, switching to postgresql from mysql, apache to nginx, and ubuntu to centos (which is my new Linux standard).  

I hope I'm not polluting the google cache with this info but I couldn't find a good guide for migrating gitlab:

  • from ubuntu to centos (debian to rpm).  No particular reason for this, just trying to make my migration even more complicated.  
  • from mysql to postgres (the latter is the preferred database for omnibus gitlab installations)
  • from gitlab source to omnibus gitlab (also the "new" preferred method).  My installation was ancient and was built from source and was a hobgob of crap that was in dire need of cleanup.  I had some components installed as the gitlab user, some as the git user...it was a mess.  
  • from apache to nginx.  The latter is the preferred web server.  It always was.  For some reason when I installed from source years ago I decided to use apache.  Don't remember why, probably just nginx ignorance.  

I really wanted to clean all of this up and get gitlab going correctly.  At this point I was stuck on 7.14 because 8.x migrations required nginx and google go and I couldn't seem to get that working with apache.  Again, ignorance...but this was just one more reason to do things correclty.  

# install your new gitlab server with the same installation as your source server.  In my case 7.14.  Probably want to use omnibus.  Make sure it's working to your specifications

# on source server...

#remove existing backups

rm -rf /home/git/gitlab/tmp/backups/*

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
Now we need to migrate mysql dump file format to postgres.  There's an excellent tutorial for that here:  https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/mysql_to_postgresql.md
Once that is done copy the file from source to destination.  I use scp:  
scp tmp/backups/* root@destination:/var/opt/gitlab/backups
# the remainder of the tasks are performed on the destination server
sudo su -
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
cd /var/opt/gitlab/backups
sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
chmod a+rx <file>
sudo gitlab-rake gitlab:backup:restore
sudo gitlab-ctl start
sudo gitlab-rake gitlab:satellites:create
sudo chmod -R ug+rwX,o-rwx /var/opt/gitlab/git-data/repositories
sudo chmod -R ug-s /var/opt/gitlab/git-data/repositories
find /var/opt/gitlab/git-data/repositories -type d -print0 | sudo xargs -0 chmod g+s
sudo gitlab-rake gitlab:check SANITIZE=true
sudo gitlab-rake gitlab:check 
And that is it.  I tested, saw no issues, shutdown the old server and pointed my DNS to the new server.  So far...so good.  
Seems like an easy process, I can assure you it took me almost a day.  I hope someone finds this post useful.

You have just read "Migrating gitlab to omnibus from source, debian to rpm, apache to nginx, and mysql to postgresql" on davewentzel.com. If you found this useful please feel free to subscribe to the RSS feed.