0

I had Gitlab on a RaspberryPi for a few years. Now I want to move the repositories to a docker based Gitlab. Best with all settings.

I have read the instructions and tried the following regarding the data:

  1. I copied the content of:

    • /etc/gitlab
    • /var/opt/gitlab/git-data
      and the gitlab container crashed...
  2. I copied the content of:

    • /etc/gitlab
    • /var/opt/gitlab
      and the gitlab container crashed...
  3. I copied the content of:

    • /etc/gitlab
      and the gitlab container run...
      Although Gitlab's settings are to be located in /etc/gitlab, no user or group data has been transferred. The "very first" screen appears, where you should set up the root password etc. Furthermore I noticed that the new Gitlab stores the repositories under /var/opt/gitlab/git-data/repositories/@hashed/ and not in the format /var/opt/gitlab/git-data/repositories/group-or-user-name/reponame.(wiki.)git like before.

So my question is:

  1. What do I have to copy to port user and group settings?
  2. How to port the repositories?
  3. What do I have to copy/back up to be able to restore the GITLAB in the future?

EDIT (A) - Experiment with containers only

docker run \
    --detach \
    --rm \
    --name gitlab \
    --network host \
    --volume ${PWD}/etc/gitlab:/etc/gitlab \
    --volume ${PWD}/var/opt/gitlab:/var/opt/gitlab \
    gitlab/gitlab-ce:latest

If I create a container with this command, do some stuff with GITLAB, than deleting the container and start a new one: This works. In this case the versions of GITLAB are the same fpr both containers.

4
  • HI Alex, please comment on wether you are trying to migrate to the same version (although in a container format) of Gitlab, or if you are changing versions as well. This will allow for better instructions for the projects migration settings. Dec 14, 2019 at 19:32
  • The source is an old version from 2017. The docker one is the latest.
    – Alex44
    Dec 14, 2019 at 20:11
  • 1
    I used gitlab-backup create to backup and gitlab-backup restore to restore the backup
    – c4f4t0r
    Dec 14, 2019 at 21:43
  • I see that is the appropriate way and I will do so in the future (Question 3 is answered). But for now I have the problem that I do not know which Gitlab version was in use and the image is not available anymore :(
    – Alex44
    Dec 14, 2019 at 23:00

1 Answer 1

0

Following the hint of c4f4t0r I solved the problem as follow:

  1. Running the old Gitlab v9.2.7 on the RaspberryPi and create a backup (Backups). Please note that in addition to the backup itself, the directory /etc/gitlab must also be backed up separately.
  2. Since restoring a backup is only possible for exactly the same version and type (CE/EE) of GitLab (Backing up and restoring GitLab), I created a Gitlab container gitlab/glitlab-ce:9.2.7-ce.0 and restored the backup in it.

    1. I have chosen the following folder structure on the docker host:
    /mnt/gitlab_ws/
    ├── backups/          <-- contains timestamp_9.2.7_gitlab_backup.tar
    ├── etc/gitlab/       <-- contains gitlab.rb; gitlab-secrets.json and ssh stuf
    ├── git-data/         <-- initially empty
    └── var/opt/gitlab/   <-- initially empty
    
    1. I have chosen the following folder structure within the docker container:
    /
    ├── etc/gitlab/
    ├── mnt/gitlab_ws/backups/   <-- to be set in */etc/gitlab/gitlab.rb*
    ├── mnt/gitlab_ws/git-data/  <-- to be set in */etc/gitlab/gitlab.rb*
    └── var/opt/gitlab/
    
    1. running gitlab
    ./run_gitlab.sh 9.2.7
    
    1. Ensure the correct write permissions. If you set the permissions on host side, the permissions within the container might be not the same. You may want to set the correct access rights after starting the container:
    docker exec -it gitlab chown -R git:git /var/opt/gitlab/ /etc/gitlab /mnt/gitlab_ws/git-data /mnt/gitlab_ws/backups
    
    1. Restore the backup
    ./restore_backup.sh
    
    1. Check if the Gitlab is now running correctly, showing all repositories and users (If not, the problem might be related to the access rights of /etc/gitlab) and the repositories have the expected content (If not, the problem might be related to the git-data path setting in /etc/gitlab/gitlab.rb or the access rights.).
  3. I bound the volume /var/opt/gitlab/ to my host in order to make it possible to upgrade Gitlab by running a gitlab container with a higher version. Keep in mind that upgrading is possible only between minor versions (Update).

./run_gitlab.sh 9.3.0

After starting the higher gitlab (the container status becomes "healthy" - this may take some time) you should now reconfigure gitlab:

./reconfigure_gitlab.sh

From now you can repeat the last to steps until you reach your desired version. You might automate this as well ;)


run_gitlab.sh

#/bin/bash

GITLAB_WS_PATH='/mnt/gitlab_ws'

if [ $# -eq 0 ]
then
        TAG='latest'
else
        TAG=$1-ce.0
fi

docker run \
        --name gitlab \
        --detach \
        --restart always \
        --network host \
        --volume $GITLAB_WS_PATH/git-data/:/mnt/gitlab_ws/git-data \
        --volume $GITLAB_WS_PATH/var/opt/gitlab:/var/opt/gitlab \
        --volume $GITLAB_WS_PATH/etc/gitlab:/etc/gitlab \
        --volume $GITLAB_WS_PATH/backups:/mnt/gitlab_ws/backups \
        gitlab/gitlab-ce:${TAG}

restore_backup.sh

#!/bin/bash

DE="docker exec -it gitlab"

${DE} gitlab-ctl stop unicorn
${DE} gitlab-ctl stop sidekiq
${DE} gitlab-rake gitlab:backup:restore
${DE} gitlab-ctl reconfigure
${DE} gitlab-ctl restart

reconfigure_gitlab.sh

#!/bin/bash

DE="docker exec -it gitlab"

${DE} gitlab-ctl stop
${DE} gitlab-ctl reconfigure
${DE} gitlab-ctl start

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .