Migrate Dockerized Gitlab

One of the great things about docker and volumes is the theory that I should be able to easily re-deploy on another docker host without issue. Unfortunately this does not appear to be the case with Gitlab.

I used this tutorial for setting up gitlab on the original Amazon linux instance, and the new Ubuntu instance that will replace it. I made sure to update the Gitlab images on both, so they should both be running the same version of Gitlab.

I then tried gracefully stopping the gitlab container on the amazon linux instance before compressing the volume using tar.gz and transferring it to the other server before extracting and re-deploying. When that didn’t work, I tried using rsync and being sure to keep the same permissions. That didn’t work either. The container would keep restarting itself and the logs showed the following error:

Error executing action run on resource 'execute[/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions]

Eventually, I cloned the volume of the Amazon Linux instance and mounted the clone on the Ubuntu instance. I then ran this command to give me access:

find . -type d -exec chmod 755 {} \;

Before then being able to re-deploy the container. Initially I had thought this was successful, but it appears to not have been and I have a fresh gitlab setup.

Question

What is the proper/ideal way to move the docker volume from one host to another in order to migrate gitlab?

@programster, Interesting discussion here on the proper backup and restore process with GitLab on docker:

J

I just finished a migration and all went well.
While testing migration, the only problem I found was when the file permission were incorrect due to using different users in the 2 systems.
Thing to note was I have external postgresql and redis docker images. I just setup gitlab docker images and copied the directories under the volume.

@hozawa that’s interesting. When you migrated did you migrate between two of the same distros or different ones? I wonder if my problem is down to the fact that I am migrating between Amazon Linux and Ubuntu which are quite different, or if I am having problems because I am not using external postgresql and redis docker images.

I’ll try again later with the useful info @jamesmundia linked.

Just replying to give a “solution”…

migrating the volumes from another host also for me did not work, and causes a restarting loop… after some diff i’ve managed to see that the issue where the owners:groups of folders of the mounted data volumes where all moved to the user “1000”

docker exec -it gitlab update-permissions fixed some of these… someothers (like the folder gitaly…) i have to chown manually (i got the right user/group comparing to the old host)

Regarding the files/folders becoming owned by 1000, I wonder if this is related to the fact that if one does not run rsync with sudo/root when using --owner and --group, then it will not preserve user/group IDs that are not recognized, and I find that it defaults back to your user ID, which will likely be 1000, which I find is the default ID for the first user on an Ubuntu system (and likely many other distros).


[screenshot from the rsync man page]

I now always use sudo when rsyncing and trying to preserve permissions, and may not have done this when I originally tried moving host. I will have to try again and report back.