[SOLVED] Stuck during upgrade gitlab-ce > accidentially deleted data directory after upgrade

Dear all,

today I intended upgrade to the latest gitlab-ce version 13 which included a postgresql upgrade.

Everything worked out smoothly like explained in the doccumentation, until I accidentially removed the /var/opt/gitlab/postgresql/data directory.
Very stupid and my bad, I know that…too tired, too fast, no excuse.

The old data directory (which I intended to delete) is still available in the folder.
Ist there a way to roll-forward or to roll-back out of this situation?

Thanks in advance & best regards


Before forgetting the details, I’ll quickly summarize what worked for the situation roughly described above:


  • Simple Centos 7 box with gitlabe-ce
  • Stuck after upgrade of gitlab from version A to version B, (major B>A) (in my case 11 to 13)
  • Upgrade required database upgrade as decribed in the online documentation
  • Upgrade went through without any problem
  • /var/opt/gitlab/postgresql/data directory gone, old /var/opt/gitlab/postgresql/data.A directory still available


  • No database available, prostgresql does not start anymore
  • Neither reconfigure upgrade or downgrade of will database work
  • in my case localhost.json file was somehow incomplete, localhost.json should have been created by reconfigure which dailed due to the postgresql service not started, due to currupted/missing data base files > the whole thing seemd to have some circular dependency

Without digging into the guts of gitlab, the following steps worked in my case:to recover from that situation:

  1. complete backup/copy of the current status
  2. sudo cp - R /var/opt/gitlab/postgresql/data.A /var/opt/gitlab/postgresql/data // create data directory with old data
  3. changed user and owner of /var/opt/gitlab/postgresql/data and conted to the right user and group for gitlab and pg
  4. sudo yum downgrade gitlab-ce.A // selected the version which fits to the db files used version information A to fit to the data base files version this table was helpful
  5. downgrade failed leaving back the data but not a working installation (cannot recap the details)
  6. sudo yum install gitlab-ce.A // resulted in a usable installation of version A using the old database files

Hope this will help to save somebodies some precious life time.