Skip to content

Refactor backup manager specs

James Fargher requested to merge backup_manager_specs into master

What does this MR do and why?

Part of #351383 (closed)

Fixes #352907 (closed)

This is continuing work started in !79809 (merged) where all the backup task logic was moved into the manager so that logic is centralised and state can be shared easier.

  • Extract pre/post warning from the DB task so that asking the user for input is centralised and can be tested easier. This stops the DB task from being so much of a special case.
  • Extract task definitions. Since backup.rake still has integration tests making sure backups on the whole work, we would like to be able to rewrite the tests just to test packing and task running alone. This should allow faster and more focused testing.
  • Refactor tests into new restricted public interface. backup.rake is the only user of Manager and it now only uses a handful of methods, anything else should be private. This requires most of the tests to be adjusted. This should allow easier internal refactoring.

How to set up and validate locally

  1. Create a backup.

    $ bundle exec rake gitlab:backup:create
    ...
    Creating backup archive: 1644531746_2022_02_11_14.8.0-pre_gitlab_backup.tar ... done
    Uploading backup archive to remote storage  ... skipped
    Deleting tmp directories ... done
    done
    done
    done
    done
    done
    done
    done
    done
    done
    Deleting old backups ... skipping
    Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 
    and are not included in this backup. You will need these files to restore a backup.
    Please back them up manually.
    Backup task is done.
  2. Restore from the backup. Note that BACKUP does not take a full path.

    $ bundle exec rake gitlab:backup:restore BACKUP=1644531746_2022_02_11_14.8.0-pre
    ...

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by James Fargher

Merge request reports