Help! Unable to restore Gitlab backup

Problem to solve

My disk crashed, I thought I was lucky I had a backup.
I installed a clean Linux and gitlab, then proceeded to restore from the backup.
It appears that the script first deleted all the contents of the database, but is unable to create empty tables.
What am I doing wrong?

I follow the guideline Restore GitLab | GitLab

sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl status

And finally the restore command
sudo gitlab-backup restore BACKUP=1710906383_2024_03_20_16.8.1

The output is as follows
Transfering ownership of /var/opt/gitlab/gitlab-rails/shared/registry to git
2024-10-16 04:06:59 UTC -- Unpacking backup ...
2024-10-16 04:08:40 UTC -- Unpacking backup ... done
2024-10-16 04:08:40 UTC -- Restoring database ...
2024-10-16 04:08:40 UTC -- Be sure to stop Puma, Sidekiq, and any other process that connects to the database before proceeding. For Omnibus installs, see the following link for more information:
https://docs.gitlab.com/ee/raketasks/backup_restore.html#restore-for-omnibus-gitlab-installations
Before restoring the database, we will remove 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
2024-10-16 04:08:53 UTC -- Cleaning the database ...
2024-10-16 04:10:50 UTC -- done
Restoring PostgreSQL database gitlab ... [DONE]
Source backup for the database ci doesn't exist. Skipping the task
2024-10-16 04:10:50 UTC -- Restoring database ... done
2024-10-16 04:10:50 UTC -- Restoring repositories ...
2024-10-16 04:10:51 UTC -- Deleting tar staging files ...
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/backup_information.yml
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/db
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/repositories
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/uploads.tar.gz
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/builds.tar.gz
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/artifacts.tar.gz
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/pages.tar.gz
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/lfs.tar.gz
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/terraform_state.tar.gz
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/registry.tar.gz
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/packages.tar.gz
2024-10-16 04:10:51 UTC -- Cleaning up /var/opt/gitlab/backups/ci_secure_files.tar.gz
2024-10-16 04:10:51 UTC -- Deleting tar staging files ... done
2024-10-16 04:10:51 UTC -- Deleting backups/tmp ...
2024-10-16 04:10:51 UTC -- Deleting backups/tmp ... done
2024-10-16 04:10:51 UTC -- Deleting backup and restore PID file ... done
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "pool_repositories" does not exist
LINE 9: WHERE a.attrelid = '"pool_repositories"'::regclass
^

/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:27:in 'columns'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:31:in 'columns_hash'
/opt/gitlab/embedded/service/gitlab-rails/app/models/pool_repository.rb:23:in '<class:PoolRepository>'
/opt/gitlab/embedded/service/gitlab-rails/app/models/pool_repository.rb:6:in '<top (required)>'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:38:in 'require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:38:in 'require'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:121:in 'restore_object_pools'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:41:in 'ensure in restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:41:in 'restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:105:in 'run_restore_task'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:249:in 'block in run_all_restore_tasks'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:247:in 'each_key'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:247:in 'run_all_restore_tasks'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:80:in 'restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:21:in 'block in restore_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:62:in 'lock_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:18:in 'restore_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:107:in 'block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:25:in 'load'
/opt/gitlab/embedded/bin/bundle:25:in '<main>'

Caused by:
PG::UndefinedTable: ERROR: relation "pool_repositories" does not exist
LINE 9: WHERE a.attrelid = '"pool_repositories"'::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:27:in 'columns'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:31:in 'columns_hash'
/opt/gitlab/embedded/service/gitlab-rails/app/models/pool_repository.rb:23:in '<class:PoolRepository>'
/opt/gitlab/embedded/service/gitlab-rails/app/models/pool_repository.rb:6:in '<top (required)>'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:38:in 'require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:38:in 'require'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:121:in 'restore_object_pools'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:41:in 'ensure in restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:41:in 'restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:105:in 'run_restore_task'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:249:in 'block in run_all_restore_tasks'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:247:in 'each_key'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:247:in 'run_all_restore_tasks'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:80:in 'restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:21:in 'block in restore_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:62:in 'lock_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:18:in 'restore_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:107:in 'block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:25:in 'load'
/opt/gitlab/embedded/bin/bundle:25:in '<main>'

Caused by:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "projects" does not exist
LINE 9: WHERE a.attrelid = '"projects"'::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:27:in 'columns'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:31:in 'columns_hash'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/postgresql_cte.rb:103:in 'build_arel'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:60:in 'enqueue_consecutive_projects'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:55:in 'enqueue_consecutive'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:36:in 'restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:105:in 'run_restore_task'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:249:in 'block in run_all_restore_tasks'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:247:in 'each_key'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:247:in 'run_all_restore_tasks'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:80:in 'restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:21:in 'block in restore_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:62:in 'lock_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:18:in 'restore_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:107:in 'block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:25:in 'load'
/opt/gitlab/embedded/bin/bundle:25:in '<main>'

Caused by:
PG::UndefinedTable: ERROR: relation "projects" does not exist
LINE 9: WHERE a.attrelid = '"projects"'::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:27:in 'columns'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:31:in 'columns_hash'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/postgresql_cte.rb:103:in 'build_arel'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:60:in 'enqueue_consecutive_projects'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:55:in 'enqueue_consecutive'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/repositories.rb:36:in 'restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:105:in 'run_restore_task'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:249:in 'block in run_all_restore_tasks'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:247:in 'each_key'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:247:in 'run_all_restore_tasks'
/opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:80:in 'restore'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:21:in 'block in restore_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:62:in 'lock_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:18:in 'restore_backup'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:107:in 'block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:25:in 'load'
/opt/gitlab/embedded/bin/bundle:25:in '<main>'
Tasks: TOP => gitlab:backup:restore
(See full trace by running task with --trace)
Transfering ownership of /var/opt/gitlab/gitlab-rails/shared/registry to registry

Versions

  • GitLab 6.8.1 installed using apt install
  • OS Raspbian 11 32-bit