• Will Chandler's avatar
    Fix exclude path for backup rsync command · cd4538bb
    Will Chandler authored
    https://gitlab.com/gitlab-org/gitlab/-/merge_requests/41706 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 command:
      rsync -a --delete --exclude=lost+found --exclude=/@pages.tmp \
        /var/opt/gitlab/gitlab-rails/shared/pages /var/opt/gitlab/backups
    
    Correct command:
      rsync -a --delete --exclude=lost+found --exclude=/pages/@pages.tmp \
        /var/opt/gitlab/gitlab-rails/shared/pages /var/opt/gitlab/backups
    cd4538bb
files.rb 5.05 KB