Retore error on 9.0.1ce

Hi I am in the process of upgrading gitlab but i want to do the upgrade as a test on a vm. I have installed the same version of gitlab on this vm and have backed up the relevant files from our live server. Now I am trying to restore to this server using the command below and I get an error. Is it something i am missing?

sudo gitlab-rake gitlab:backup:restore BACKUP=1612443980_2021_02_04

Do you want to continue (yes/no)? yes
Removing all tables. Press Ctrl-C within 5 seconds to abort
Cleaning the database …
rake aborted!
PG::ConnectionBad: 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”?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:27:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:51:in block (3 levels) in <top (required)>’
/opt/gitlab/embedded/bin/bundle:22:in load' /opt/gitlab/embedded/bin/bundle:22:in
Tasks: TOP => gitlab:db:drop_tables
(See full trace by running task with --trace)

Full trace output
** Invoke gitlab:backup:restore (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute gitlab:backup:restore
Unpacking backup … done
Before restoring the database we recommend removing all existing
tables to avoid future upgrade problems. Be aware that if you have
custom tables in the GitLab database these tables and all data will be
removed.

Do you want to continue (yes/no)? yes
Removing all tables. Press Ctrl-C within 5 seconds to abort
Cleaning the database …
** Invoke gitlab:db:drop_tables (first_time)
** Invoke environment
** Execute gitlab:db:drop_tables
rake aborted!
PG::ConnectionBad: 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”?
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in initialize' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in new’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in connect' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in initialize’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in new' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in postgresql_connection’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in new_connection' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in checkout_new_connection’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in acquire_connection' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in block in checkout’
/opt/gitlab/embedded/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in checkout’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in block in connection' /opt/gitlab/embedded/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in connection' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in retrieve_connection’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:113:in retrieve_connection' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:87:in connection’
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:27:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:240:in block in execute’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:235:in each' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:235:in execute’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:179:in block in invoke_with_call_chain' /opt/gitlab/embedded/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:172:in invoke_with_call_chain' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:165:in invoke’
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:51:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:240:in block in execute’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:235:in each' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:235:in execute’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:179:in block in invoke_with_call_chain' /opt/gitlab/embedded/lib/ruby/2.3.0/monitor.rb:214:in mon_synchronize’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:172:in invoke_with_call_chain' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:165:in invoke’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:150:in invoke_task' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in block (2 levels) in top_level’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in each' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:106:in block in top_level’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:115:in run_with_threads' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:100:in top_level’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:78:in block in run' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:176:in standard_exception_handling’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/application.rb:75:in run' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/rake-10.5.0/bin/rake:33:in <top (required)>’
/opt/gitlab/embedded/bin/rake:22:in load' /opt/gitlab/embedded/bin/rake:22:in <top (required)>’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in load' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in kernel_load’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in run' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in exec’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in invoke_command’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in dispatch' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in dispatch’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in start' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in start’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/exe/bundle:34:in block in <top (required)>' /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in with_friendly_errors’
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.13.7/exe/bundle:26:in <top (required)>' /opt/gitlab/embedded/bin/bundle:22:in load’
/opt/gitlab/embedded/bin/bundle:22:in `’
Tasks: TOP => gitlab:db:drop_tables

Hi, what were your steps for restoring. From what I remember, when I did something similar, I did something like this:

  1. Installed the gitlab version that I required which was same as on my original server.
  2. Placed gitlab.rb in /etc/gitlab along with the gitlab-secrets.json
  3. Ran gitlab-ctl reconfigure
  4. gitlab-ctl restart
  5. Place backup file in /var/opt/gitlab/backups
  6. Ran restore command.

I’m pretty sure that after installing gitlab, you must have an empty install configured and running so that it can access the postgres instance, so I expect your problems might be because of this.

Hi Ian,

So as the test server is a vm I rebuilt the vm and reinstalled gitlab same version as on my live server. Then I followed your steps and this all worked like a treat and I can get into my gitlab webpage. Thanks for that. I was wondering the next steps are gonna be to start upgrading to a new a version. Do you recommend the single node zero downtime install in the doc below

https://docs.gitlab.com/omnibus/update/README.html#single-node-deployment

We have a single node, I have enough backups to recover it in the event of problems, and since our team is small 10-15 users, we don’t really have a need for multiple servers because we aren’t overloading the server or slowing it down.

A single node will have downtime, especially during upgrades, but this is generally 5 minutes to download the rpm/deb, install and do the DB migrations.