Fix exclude path for backup rsync command
What does this MR do?
!41706 (merged) attempted to prevent rsync
from including tmp directories when
preparing backups with STRATEGY=copy
, but used an incorrect path that
caused rsync
to continue to include these directories.
The --exclude
argument was passed with the tmp directory name with a
leading slash, but this is not the correct format when no trailing slash
is used on the source path. rsync
will chdir
to the parent directory
in this scenario, e.g. /var/opt/gitlab/gitlab-rails/shared
for pages,
treating that location as /
in the --exclude
path.
We need to include full path from the source directory to the tmp
directory in --exclude
, which means adding the basename of
app_files_dir
.
- Current
rsync
command:
$ /opt/gitlab/embedded/bin/rsync -a --delete --exclude=lost+found --exclude=/@pages.tmp /var/opt/gitlab/gitlab-rails/shared/pages /tmp/backup-out; find /tmp/backup-out
/tmp/backup-out
/tmp/backup-out/pages
/tmp/backup-out/pages/@pages.tmp
/tmp/backup-out/pages/other
/tmp/backup-out/pages/other/2
/tmp/backup-out/pages/test
/tmp/backup-out/pages/test/1
- Corrected
rsync
command:
$ /opt/gitlab/embedded/bin/rsync -a --delete --exclude=lost+found --exclude=/pages/@pages.tmp /var/opt/gitlab/gitlab-rails/shared/pages /tmp/backup-out; find /tmp/backup-out
/tmp/backup-out
/tmp/backup-out/pages
/tmp/backup-out/pages/other
/tmp/backup-out/pages/other/2
/tmp/backup-out/pages/test
/tmp/backup-out/pages/test/1
Does this MR meet the acceptance criteria?
Conformity
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
Edited by Will Chandler (ex-GitLab)