On the new server running Debian 8, we’re proceed to create a fresh copy of Gitlab Community edition. For demonstration, I have created a Digitalocean droplet. (Aside: Digitalocean is a cloud based on-the-fly VPS service. To try this tutorial, you may Signup to DO using my referral code and get a free $10 credit to try it out. Click here).

Create a Debian 8 jessie VPS with 512 MB RAM (512 MB is enough for running Gitlab. If you wish to try with more RAM, you’re free to).


For latest package, refer: https://about.gitlab.com/downloads/archives/

Now install essential packages:

apt-get update && apt-get install openssh-server postfix emacs -y
wget https://downloads-packages.s3.amazonaws.com/debian-8.0/gitlab-ce_7.10.1~omnibus.2-1_amd64.deb

For Debian 7 64bit, the package is at https://downloads-packages.s3.amazonaws.com/debian-7.8/gitlab-ce_7.10.1~omnibus.2-1_amd64.deb

I install emacs because it is my preferred editor. You may use your favorite editor-vim, nano etc.

Before backing up, you need to upgrade the version of gitlab on the old server to the same version as the one you will be installing to the new server.
So on the old server, I will upgrade 7.9.2 to 7.10.1 by following instructions given here: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/update.md#updating-from-gitlab-6-6-x-and-higher-to-the-latest-version
For choosing update instructions, see here: https://about.gitlab.com/update/

Login via ssh to the old server where gitlab is already running, and issue the following command from shell:

sudo gitlab-ctl stop unicorn && sudo gitlab-ctl stop sidekiq && sudo gitlab-ctl stop nginx
wget https://downloads-packages.s3.amazonaws.com/debian-7.8/gitlab-ce_7.10.1~omnibus.2-1_amd64.deb
sudo dpkg -i gitlab-ce_7.10.1~omnibus.2-1_amd64.deb

Once you receive a message of “Upgrade complete!”, issue the following:

sudo gitlab-ctl restart

Confirm that you can login, to confirm that everything went smoothly.

Now, backup gitlab.

sudo gitlab-rake gitlab:backup:create

On the new server, download and install gitlab CE:

wget https://downloads-packages.s3.amazonaws.com/debian-8.0/gitlab-ce_7.10.1~omnibus.2-1_amd64.deb
dpkg -i gitlab-ce_7.10.1~omnibus.2-1_amd64.deb
gitlab-ctl reconfigure

Once it’s completed, navigate to http://yourip.com/ and login with username root and password 5iveL!fe. Choose a new password when prompted. Gitlab install is now over. Now we’ll transfer data from the old server.

The following instructions document setting up key authentication between two servers. This is optional. Debian jessie by default removes password based ssh by default. If you still have password based ssh authentication (which was default on previous debian versions), you can just do scp of files and provide passwords. If the latter is true in your case, skip ahead to the scp command below.

In your ssh terminal in the new server, send the public key for your ssh key to the new server.
Since I usually change the ssh port for security reasons, and also disable password login for root ssh user, I have to setup keybased login.

In your old server, make changes to ~/.ssh/config

emacs ~/.ssh/config
Host git.yourserver.com
     User root
     Identityfile /root/.ssh/id_rsa
     Port 65678

This sets up ssh so that you can connect to your server with just ssh git.yourserver.com, and ssh will take care of choosing the proper key and port. Otherwise, specifying the port and key each time is tedious. Here, should be replaced by your server’s ip.

In your new server, make similiar changes corresponding to the old server.

On your old server, transfer the latest backup from /var/opt/gitlab/backups/ to the new server:

scp /var/opt/gitlab/backups/1430619604_gitlab_backup.tar [email protected]:/var/opt/gitlab/backups/

Now on the new server, execute the following to restore from the transferred backup.

sudo gitlab-rake gitlab:backup:restore BACKUP=1430619604

If you receive an error about unable to unpack due to a permission problem, just run a chmod go+r on the backup file.

When everything is over, run the following for good measure:

sudo gitlab-ctl restart