Update 2016-05-13: The following procedure works perfectly for migrations from version 8.0.4 to 8.7.5
A few days ago, I had to migrate a Gitlab instance installed in Docker from version 8.04 to 8.2.0. I followed the exact steps described in GitLab Docker images documentation. But it was not so easy! Of cource, it required some more! Thus, after 4 hours of errors, searching and trials I found the way! Thank god!
In this article we will make the assumption that Gitlab volumes are stored in /home/bob/docker-data/gitlab directory. Here are the exact steps I followed to make a successful migration:
- Stop docker container
1docker stop gitlab - Backup docker volumes (all gitlab files)
1 2 3backupDate=$(date +"%Y%m%d%H%M%S") \ && cd /home/bob/docker-data/ \ && sudo tar zvcf gitlab-data-${backupDate}.tar.gz gitlab/ - Optionally backup docker image
1docker save -o /home/bob/gitlab-ce-image.tar gitlab/gitlab-ce:latest - Remove docker container
1docker rm gitlab - Download the latest Gitlab docker image
1sudo docker pull gitlab/gitlab-ce:latest - After the image is downloaded create and run the container
1 2 3 4 5 6 7 8 9 10docker run -d \ --hostname 192.168.1.1 \ --publish 8443:443 --publish 8082:80 --publish 2224:22 \ --name gitlab \ --restart always \ --volume /etc/localtime:/etc/localtime \ --volume /home/bob/docker-data/gitlab/config:/etc/gitlab \ --volume /home/bob/docker-data/gitlab/logs:/var/log/gitlab \ --volume /home/bob/docker-data/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest - The container starts and we observer the logs via:
1docker logs -f --tail 10 gitlab - The docker container started and we observed in the logs:
These are two known permission issues described in official documentation and in issue #9611. In order to overcome them, we execute:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51[2015-11-26T15:12:26+02:00] INFO: Retrying execution of execute[create gitlab database user], 19 attempt(s) left [2015-11-26T15:12:28+02:00] INFO: Retrying execution of execute[create gitlab database user], 18 attempt(s) left ... (some lines omitted) ... [2015-11-26T15:13:09+02:00] INFO: Retrying execution of execute[create gitlab database user], 0 attempt(s) left Error executing action `run` on resource 'execute[create gitlab database user]' Mixlib::ShellOut::ShellCommandFailed Expected process to exit with [0], but received '2' ---- Begin output of /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d template1 -c "CREATE USER gitlab" ---- STDOUT: STDERR: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"? ---- End output of /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d template1 -c "CREATE USER gitlab" ---- Ran /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d template1 -c "CREATE USER gitlab" returned 2 Resource Declaration: # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/postgresql.rb 153: execute "create #{sql_user} database user" do 154: command "#{bin_dir}/psql --port #{pg_port} -h #{postgresql_socket_dir} -d template1 -c \"CREATE USER #{sql_user}\"" 155: user postgresql_user 156: # Added retries to give the service time to start on slower systems 157: retries 20 158: not_if { !pg_helper.is_running? || pg_helper.user_exists?(sql_user) } 159: end 160: Compiled Resource: # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/postgresql.rb:153:in `block in from_file' execute("create gitlab database user") do action [:run] retries 20 retry_delay 2 default_guard_interpreter :execute command "/opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d template1 -c \"CREATE USER gitlab\"" backup 5 returns 0 user "gitlab-psql" declared_type :execute cookbook_name "gitlab" recipe_name "postgresql" not_if { #code block } endand finally we restart the docker container:1 2docker exec -it gitlab update-permissions docker exec gitlab chown -R gitlab-redis /var/opt/gitlab/redis1docker restart gitlab - Then we have to check if the database migration was successfull and avoid issue #3255. Thus, we log into bash shell:
and we check the db migration status:
1docker exec -t -i gitlab /bin/bashIf everything is stated as1sudo gitlab-rake db:migrate:statusup, we are OK. However, if we noticedownmigrations like thiswe have to rerun the database migration ourserlves:1 2 3up 20150920161119 Add line code to sent notification down 20150924125150 Add project id to ci commit down 20150924125436 Migrate project id for ci commitsWhen it finishes we have to check that everything went ok:1sudo gitlab-rake db:migrate1sudo gitlab-rake db:migrate:status - While being inside the container bash shell, we reconfigure the installation:
and then check that everything went ok:
1sudo gitlab-ctl reconfigure1sudo gitlab-rake gitlab:check - If everything is OK, then the command:
must return something like this:
1sudo gitlab-rake gitlab:env:info RAILS_ENV=production1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26System information System: Ubuntu 14.04 Current User: git Using RVM: no Ruby Version: 2.1.7p400 Gem Version: 2.2.5 Bundler Version:1.10.6 Rake Version: 10.4.2 Sidekiq Version:3.3.0 GitLab information Version: 8.2.0 Revision: d6bcf44 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://192.168.1.1:8082 HTTP Clone URL: http://192.168.1.1:8082/some-group/some-project.git SSH Clone URL: [email protected]:some-group/some-project.git Using LDAP: yes Using Omniauth: no GitLab Shell Version: 2.6.7 Repositories: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/ Git: /opt/gitlab/embedded/bin/git - Finally we have to clear Redis cache, or we will face the issue #3619 or issue #3609:
1sudo gitlab-rake cache:clear - After that you will be able to login properly to http://localhost:8082