Based on the IT journey of Michael Rickert

Gitlab server migration

As our gitlab server began seeing more usage in production I decided it was time to update it to the latest and greatest version. The only issue with this is that our gitlab server was ~5 versions behind the latest and following the upgrade track would be far too time consuming. So I built out a new gitlab server with the latest version and set about migrating the repositories over, here are the steps I used to do just that:

1. Create the new gitlab server following the instructions provided here: https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md

2. Create a new group on the new gitlab server while accessing the admin area of gitlab:


3. SCP or through other means copy the repositories from the old git server to the new server

4. Give the newly copied files proper permissions:

chown -R git:git /home/git/repositories
chmod 770 -R /home/git/repositories


5. Import the new repositories

cd /home/git/gitlab
bundle exec rake gitlab:import:repos RAILS_ENV=production


6. Link the new hooks for git, replace ‘sample.git’ with the name of each of your imported repositories

sudo -u git ln -sf /home/git/gitlab-shell/hooks/update /home/git/repositories/repositories/sample.git/hooks/update
sudo -u git ln -sf /home/git/gitlab-shell/hooks/post-receive /home/git/repositories/repositories/sample.git/hooks/post-receive

7. Create any needed satallites:

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production

8. Run a check on gitlab and make sure everything successfully imported

cd /home/git/gitlab
bundle exec rake gitlab:check RAILS_ENV=production

9. Add users to the newly imported/created group using the gitlab web GUI and admin area

10. Test cloning as well as pushing to the new repository and you’re all done!

Leave a Reply