Skip to content

Add external MR diffs to `gitlab-backup` task

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do and why?

This MR adds External Merge Request diffs to be included in GitLab backups.

Closes #438777

How to set up and validate locally

  1. Enable External storage for MR diffs as described here
  2. Create MR in any repository and make sure that merge_request_diffs/mr-<mr_id>/diff-<diff_id> was created in Settings.external_diffs.storage_path folder (usually </path/to/gdk>/gitlab/shared/external-diffs)
  3. Run the following rake task to run a backup of only the DB and External diffs: bundle exec rake gitlab:backup:create SKIP=repositories,uploads,builds,artifacts,pages,lfs,terraform_state,registry,packages,ci_secure_files
  4. Note the backup name in the output, something like Backup 1717151650_2024_05_31_17.1.0-pre is done.
  5. Once the backup completes look in tmp/backups in the gitlab project and confirm that a new backup tar file has been created
  6. Untar that file and confirm a external_diffs tar file has been created
  7. Untar that file and confirm the merge_request_diffs/mr-<mr_id>/diff-<diff_id> was included in the backup
  8. Clean up Settings.external_diffs.storage_path directory, so we can restore it from the backup. Note: UI page with diff of MR that was created in step 2 will not load (because diff files were removed by use)
  9. Now run bundle exec rake gitlab:backup:restore BACKUP=1717151650_2024_05_31_17.1.0-pre, replacing 1717151650_2024_05_31_17.1.0-pre with your backup name (this takes a while)
  10. Once the restore is done, confirm that the files in Settings.external_diffs.storage_path directory are the same as in step 2 and diff for MR created in step 2 can be seen in UI
Edited by Michael Kozono

Merge request reports