Fix postgres upgrade error when upgrade Gitlab-CE from 8.x to 9.0




Right after Gitlab 9.0 was released, I upgraded our gitlab 8.x server and got stucked at PostGres upgrade with the following error:

...
Creating temporary data directory:Error creating new directory: /var/opt/gitlab/postgresql/data.9.6.1
...

I'd tried many things including changing the folder ownership and using a different tmp folder for postgres upgrade but it's still the same. Luckily, by searching through the Gitlab community edition issues site, I found out someone had a similar problem. I tried what they suggested and it worked. Here are the steps I had done to fix the upgrade:

1. Change the gitlab-psql users shell to /bin/bash (as root):

chsh -s /bin/bash gitlab-psql

2. Run dpkg-reconfigure dash and select NO will link /bin/sh to /bin/bash

3. Run the Gitlab upgrade again and everything was fine:

gitlab-ctl upgrade


Reference: https://gitlab.com/gitlab-org/gitlab-ce/issues/29907