Error when trying to restore GitLab backup

Good morning, I hope you are well!

I use GitLab on version 16.10.1 and when trying to restore my backup (from the same version) I got the following error:

root@37f36c134253:/# gitlab-backup restore BACKUP=/var/opt/gitlab/backups/2024-04-12-16.10.1-ee
Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB.
Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB.
Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB.
Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB.
Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB.
Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB.
Rails Error: Unable to access log file. Please ensure that /opt/gitlab/embedded/service/gitlab-rails/log/production.log exists and is writable (i.e. make it writable for user and group: chmod 0664 /opt/gitlab/embedded/service/gitlab-rails/log/production.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
rake aborted!
Cannot load database configuration:
File "/opt/gitlab/embedded/service/gitlab-rails/config/database.yml" is a symlink that does not point to a valid file
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/patch/database_config.rb:15:in `database_configuration'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:7:in `<top (required)>'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/helpers.rake:7:in `block in <top (required)>'
/opt/gitlab/embedded/bin/bundle:25:in `load'
/opt/gitlab/embedded/bin/bundle:25:in `<main>'

Caused by:
File "/opt/gitlab/embedded/service/gitlab-rails/config/database.yml" is a symlink that does not point to a valid file
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/patch/database_config.rb:15:in `database_configuration'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:7:in `<top (required)>'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/helpers.rake:7:in `block in <top (required)>'
/opt/gitlab/embedded/bin/bundle:25:in `load'
/opt/gitlab/embedded/bin/bundle:25:in `<main>'
Tasks: TOP => environment
(See full trace by running task with --trace)
root@37f36c134253:/#

I searched and didn’t find any related topics, does anyone have any idea what could be causing this error?

Looking at the error message, these lines stand out to me as indicator of root cause of your problem here:

Cannot load database configuration:
File "/opt/gitlab/embedded/service/gitlab-rails/config/database.yml" is a symlink that does not point to a valid file

Caused by:
File "/opt/gitlab/embedded/service/gitlab-rails/config/database.yml" is a symlink that does not point to a valid file

It sounds like your GitLab installation has a bad symlink or that /var/opt/gitlab/gitlab-rails/etc/database.yml was corrupted or deleted. Both the symlink and the file it points to should be created or updated when you make changes to gitlab.rb and run gitlab-ctl reconfigure.

I also see an unrelated issue with your log files:

Rails Error: Unable to access log file. Please ensure that /opt/gitlab/embedded/service/gitlab-rails/log/production.log exists and is writable (i.e. make it writable for user and group: chmod 0664 /opt/gitlab/embedded/service/gitlab-rails/log/production.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.

To troubleshoot further, can you please provide the output of the following commands?

ls -l /opt/gitlab/embedded/service/gitlab-rails/config/database.yml
ls -l /var/opt/gitlab/gitlab-rails/etc/database.yml
ls -l /opt/gitlab/embedded/service/gitlab-rails/log/production.log
ls -l /var/log/gitlab/gitlab-rails/production.log
2 Likes

Thanks! As soon as I return to service I will check!