How to setup Gitalb CE 8.* to read-only state for all users?


I am going to upgrade Gitlab CE 8.6.7 running on RHEL 6 to the lateste Gitalb CE 8.*. It turned out that the latest one (8.17.5) required glibc which is not available on RHEL 6. So the only option is to go for RHEL 7 (which is fine for me).
So the idea is to:

  1. install the same gitlab version (8.6.7) on RHEL 7
  2. make backup on RHEL 6, copy over to RHEL 7 and restore
  3. on RHEL 7 upgrade 8.6.7 to the latest 8.*
    I have tested all the steps in non-prod environment but where is comes to the production I have a problem with point 2. - the backup. I need to setup the current running 8.6.7 into read-only mode to be sure there are no commits during the backup process. Because we have hundreds of developers this is not an option to manually set every repo as read-only. Is there any another central or automated way to set it up read-only ?

Best regards

i think the easiest way to do this temporarily install a global git pre-recieve hook which returns a non zero exit code. Even better you may just print a message to stdout in the hook that the repositories are currently read-only until the update is done.

All other solutions I can think of (reducing user permissions in the database, chowning git-data etc.) are not as easily revertible.

Regards Mirko

thanks for your post.
I found the pre-receive hook and changed it to return non-zero value and everythink is working as I wanted.
But how can I print a message ? It is in ruby but can I use just simple ruby print output or do I have to use some gitlab-compatible print command ?


Well, we use python for our hooks. We just print to stdout or stderr, sorry, I am not in the office right now, so I can not tell which stream we use. I think it is stderr, because some hooks process stdout via stdin, so it has to be stderr.

Hi Mirko,

does that mean that it doesn’t have to be ruby script and I can just do ‘exit 1’ in any script (python/bash/some other) ?

hello, yes, I think so. As stated we use python and just exit with 1, see for where to place hooks, we put them in the directories outlined at the help page.