backup.rake assumes that a repositories directory exists to tar

Summary

When there are no repositories to backup or eventually when repositories are backed up directly to object storage gitaly#3633 (closed) there is no repositories directory to add to the backup tar file. When this happens the backup fails:

$ bundle exec rake gitlab:backup:create
 Warning 
  You are running as user root, we hope you know what you are doing.
  Things may work/fail for the wrong reasons.
  For correct results you should run this as user git.
2021-07-28 03:53:43 +0000 -- Dumping database ... 
Dumping PostgreSQL database gitlabhq_test ... [DONE]
2021-07-28 03:53:45 +0000 -- done
2021-07-28 03:53:45 +0000 -- Dumping repositories ...
2021-07-28 03:53:46 +0000 -- done
2021-07-28 03:53:46 +0000 -- Dumping uploads ... 
2021-07-28 03:53:46 +0000 -- done
2021-07-28 03:53:46 +0000 -- Dumping builds ... 
2021-07-28 03:53:46 +0000 -- done
2021-07-28 03:53:46 +0000 -- Dumping artifacts ... 
2021-07-28 03:53:46 +0000 -- done
2021-07-28 03:53:46 +0000 -- Dumping pages ... 
2021-07-28 03:53:46 +0000 -- done
2021-07-28 03:53:46 +0000 -- Dumping lfs objects ... 
2021-07-28 03:53:46 +0000 -- done
2021-07-28 03:53:46 +0000 -- Dumping container registry images ... 
2021-07-28 03:53:46 +0000 -- [DISABLED]
Creating backup archive: 1627444426_2021_07_28_14.2.0-pre_gitlab_backup.tar ... tar: repositories: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
creating archive 1627444426_2021_07_28_14.2.0-pre_gitlab_backup.tar failed
rake aborted!
Backup::Error: Backup failed
/builds/gitlab-org/gitlab/lib/backup/manager.rb:36:in `block in pack'
/builds/gitlab-org/gitlab/lib/backup/manager.rb:27:in `chdir'
/builds/gitlab-org/gitlab/lib/backup/manager.rb:27:in `pack'
/builds/gitlab-org/gitlab/lib/tasks/gitlab/backup.rake:27:in `block (3 levels) in <main>'
/builds/gitlab-org/gitlab/vendor/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:backup:create
(See full trace by running task with --trace)

Steps to reproduce

Example Project

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes