Add external MR diffs to `gitlab-backup` task
requested to merge gitlab-community/gitlab:438777-add-external-mr-diffs-to-gitlab-backup-task into master
-
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 (closed)
How to set up and validate locally
- Enable External storage for MR diffs as described here
- Create MR in any repository and make sure that
merge_request_diffs/mr-<mr_id>/diff-<diff_id>
was created inSettings.external_diffs.storage_path
folder (usually</path/to/gdk>/gitlab/shared/external-diffs
) - 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
- Note the backup name in the output, something like
Backup 1717151650_2024_05_31_17.1.0-pre is done.
- Once the backup completes look in
tmp/backups
in the gitlab project and confirm that a new backup tar file has been created - Untar that file and confirm a
external_diffs
tar file has been created - Untar that file and confirm the
merge_request_diffs/mr-<mr_id>/diff-<diff_id>
was included in the backup - 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) - Now run
bundle exec rake gitlab:backup:restore BACKUP=1717151650_2024_05_31_17.1.0-pre
, replacing1717151650_2024_05_31_17.1.0-pre
with your backup name (this takes a while) - 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