Restoring backup on new instance fails

Hi there,

So 2 months ago, I got an issue where I was not able to update GitLab-ce to the latest version. It was due to a bug that is fixed now. But that bug killed my instance. Even after the update, my instance was not able to boot.

So I decided to restore a backup on a new fresh install. I deleted my current instance and installed the right one based on my backup 14.1.1. I tried today to restore my backup, but I got this:

2022-09-01 17:42:13 +0000 – Cleaning the database …
rake aborted!
ActiveRecord::StatementInvalid: PG::DependentObjectsStillExist: ERROR: cannot drop schema gitlab_partitions_dynamic because other objects depend on it
DETAIL: table gitlab_partitions_dynamic.web_hook_logs_000000 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202103 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202104 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202105 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202106 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202107 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202108 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202109 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202110 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202111 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202112 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202201 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202202 depends on schema gitlab_partitions_dynamic
table gitlab_partitions_dynamic.web_hook_logs_202203 depends on schema gitlab_partitions_dynamic
HINT: Use DROP … CASCADE to drop the dependent objects too.
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:52:in block (4 levels) in <top (required)>' /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:51:in each’
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:51:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:71:in block (3 levels) in <top (required)>’
/opt/gitlab/embedded/bin/bundle:23:in load' /opt/gitlab/embedded/bin/bundle:23:in

I followed this for the procedure: Restore GitLab | GitLab

Please don’t tell me that my backup is on a buggy version of Gitlab…
What can I do?

Thanks.

When I do gitlab-rake gitlab:env:info I get this everytime:

System information
System: Ubuntu 18.04
Current User: git
Using RVM: no
Ruby Version: 2.7.2p137
Gem Version: 3.1.4
Bundler Version:2.1.4
Rake Version: 13.0.3
Redis Version: 6.0.14
Git Version: 2.32.0
Sidekiq Version:5.2.9
Go Version: unknown
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation “namespaces” does not exist
LINE 8: WHERE a.attrelid = ‘“namespaces”’::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table.rb:25:in columns' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table.rb:29:in columns_hash’
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/info.rake:50:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/bin/bundle:23:in load’
/opt/gitlab/embedded/bin/bundle:23:in `<main>’

Caused by:
PG::UndefinedTable: ERROR: relation “namespaces” does not exist
LINE 8: WHERE a.attrelid = ‘“namespaces”’::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table.rb:25:in columns' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table.rb:29:in columns_hash’
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/info.rake:50:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/bin/bundle:23:in load’
/opt/gitlab/embedded/bin/bundle:23:in `<main>’
Tasks: TOP => gitlab:env:info
(See full trace by running task with --trace)

The instance is new, I just reboot the server a couple of times and I ran gitlab-ctl reconfigure…

Seems that some migrations are stucked… When I do db:migrate:status, I have many as down…
Trying to reset the DB

root@:/home/machin# sudo gitlab-rake gitlab:setup
This will create the necessary database tables and seed the database.
You will lose any previous data stored in the database.
Do you want to continue (yes/no)? yes

rake aborted!
ActiveRecord::NoEnvironmentInSchemaError:

Environment data not found in the schema. To resolve this issue, run:

    bin/rails db:environment:set RAILS_ENV=production

/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:35:in setup_db' /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:7:in block (2 levels) in <top (required)>’
/opt/gitlab/embedded/bin/bundle:23:in load' /opt/gitlab/embedded/bin/bundle:23:in
Tasks: TOP => db:reset => db:drop => db:check_protected_environments
(See full trace by running task with --trace)

:sob: :sob: :sob: