Migrate all your Gitlab repositories, users, issues, wikis etc to a new server

A step by step guide to moving your existing GitLab repositories to a new server all in one go. 

A few months back I moved a lot of my code off GitHub and set up my own GitLab server on Rackspace. If you haven’t checked out GitLab yet, it’s a great very active open source project that basically mimics a GitHub environment on your own server, without the $5000/y price tag (which I think would be well worth it, if I actually made any money from most of my code, but it’s all my own projects and ideas so it’s not worth it to me).

The following guide requires that you have the same version of GitLab on both the existing and the destination server, so use the upgrade guides to do that if you need to. If that isn’t an option, your only other choice is really to one by one open the repo’s up to the public, then on the new server use gitlab to create a new repo from an ‘existing’ one, supplying the URL in the process (but you will probably lose all the issue data, wiki, wall, etc). So if you can, update it first.

In my case, I was moving from an Ubuntu 12.04LTS vps on Rackspace, on which I had Gitlab patched up to 6.5-stable, to a Digital Ocean droplet that I used their ‘GitLab 6.6.5’ Application to create. So, I needed to patch them both to 6.7, pretty painless with the great upgrade guides.

So, the process:

  1. Make the new vps and install Gitlab on it – not covered, plenty of other places to get this info from. You also need to figure out the DNS setting so you can access it. Digital Ocean seems ok so far for me and they have a 1 click installer for GitLab.
  2. Make sure you have the same version on this box as the new one
    cd /home/git/gitlab && git status
  3. Remove any existing backups
    rm -rf /home/git/gitlab/tmp/backups/*
  4. Run a backup from the source machine:
    cd /home/git/gitlab
    sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
  5. Use RSYNC to copy your backup to the new server.
    rsync -azP --delete /home/git/gitlab/tmp/backups/ root@YOURSERVER:/home/git/gitlab/tmp/backups
  6. Restore the backup on the new server!
    cd /home/git/gitlab
    sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
  7. Check it over and when satisfied, delete your old server 🙂

Leave a Reply