Restore Gitlab only with database, etc & /var/opt


It’s possible to restore a Gitlab CE instance, just using an SQL export of the database? I don’t have the “gitlab:backup:create” backup, just the PostgreSQL database export.

My Gitlab version 9.2.2

I tried:

  • Installing a new 9.2.2 instance, using another database (external postgresql server), run “gitlab-ctl reconfigure” and “gitlab-ctl start”. And a new Gitlab CE 9.2.2 instance is running.
  • Restore /etc/gitlab & /var/opt/gitlab
  • gitlab-ctl reconfigure -> OK!
  • gitlab-rake gitlab:check -> OK!
  • gitlab-ctl restart -> OK!
  • Accessing via Web


  • Setting right permissions, now I see all repos listed in Gitlab interfac, but all of them are empty.

  • gitlab-rake gitlab:check --trace shows hooks errors:

    20 blalblabla / use ... wrong or missing hooks
    21 Try fixing it:
    22   sudo -u git -H /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks /var/opt/gitlab/git-data/repositories
    23   Check the hooks_path in config/gitlab.yml
    24   Check your gitlab-shell installation
    25  For more information see:
    26   doc/install/ in section "GitLab Shell"
    27  Please fix the error above and rerun the checks.

Any idea?

Thanks in advance.

The error message you quoted has explicit instructions for how to fix this.
Did you try running this command?


Yes, that specific error was a permission thing.
Anyway, I finally achieved it. I’ll post here the complete procedure after do some tests to ensure everything is working ok.

Thanks anyway.

Hi again,

The procedure to restore everything using just the exported DB and /etc/gitlab & /var/opt/gitlab folder backups, was the following:

  1. Install a fresh Gitlab instance using the same version I had (9.2.2 in my case)
  2. Reconfigure & start that instance to test it’s working.
  3. Stop Gitlab, replace gitlab.rb & config from /etc, pointint to a copy of the exported database (in my case using an external PostgreSQL server)
  4. Restore folder /var/opt/gitlab
  5. Fix permissions in /var/opt, comparing to another Gitlab installation I had. This was critical to make it work
  6. Reconfigure & start again. Working!

In my case there was one repository (the “complex” one) that was not working after this. The solution was:

  1. Rename it
  2. Delete it from Gitlab web
  3. Run clean_pending_delete_project.rb ( ) from the gitlab-rails console
  4. Copy “myrepo.git” folder backed up to “/var/opt/gitlab/git-data/repositories/mynamespace/myrepo.git” and check were permissions “git:git”
  5. Run “gitlab-rake gitlab:import:repos”
  6. Run “gitlab-rake gitlab:check --trace” to check everything is ok
  7. Running! :slight_smile:

Best regards!


What happen if i just have /var/opt/gitlab
(I was using the defailt postgresql database)