Commit 90d65ded authored by James Lopez's avatar James Lopez

Merge branch 'wc-rsync-exclude-path' into 'master'

Fix exclude path for backup rsync command

See merge request gitlab-org/gitlab!52503
parents ac05f68e cd4538bb
---
title: Fix exclude path for backup rsync command
merge_request: 52503
author:
type: fixed
...@@ -137,7 +137,7 @@ module Backup ...@@ -137,7 +137,7 @@ module Backup
if s == DEFAULT_EXCLUDE if s == DEFAULT_EXCLUDE
'--exclude=' + s '--exclude=' + s
elsif fmt == :rsync elsif fmt == :rsync
'--exclude=/' + s '--exclude=/' + File.join(File.basename(app_files_dir), s)
elsif fmt == :tar elsif fmt == :tar
'--exclude=./' + s '--exclude=./' + s
end end
......
...@@ -150,7 +150,7 @@ RSpec.describe Backup::Files do ...@@ -150,7 +150,7 @@ RSpec.describe Backup::Files do
it 'excludes tmp dirs from rsync' do it 'excludes tmp dirs from rsync' do
expect(Gitlab::Popen).to receive(:popen) expect(Gitlab::Popen).to receive(:popen)
.with(%w(rsync -a --delete --exclude=lost+found --exclude=/@pages.tmp /var/gitlab-pages /var/gitlab-backup)) .with(%w(rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup))
.and_return(['', 0]) .and_return(['', 0])
subject.dump subject.dump
...@@ -158,7 +158,7 @@ RSpec.describe Backup::Files do ...@@ -158,7 +158,7 @@ RSpec.describe Backup::Files do
it 'retries if rsync fails due to vanishing files' do it 'retries if rsync fails due to vanishing files' do
expect(Gitlab::Popen).to receive(:popen) expect(Gitlab::Popen).to receive(:popen)
.with(%w(rsync -a --delete --exclude=lost+found --exclude=/@pages.tmp /var/gitlab-pages /var/gitlab-backup)) .with(%w(rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup))
.and_return(['rsync failed', 24], ['', 0]) .and_return(['rsync failed', 24], ['', 0])
expect do expect do
...@@ -168,7 +168,7 @@ RSpec.describe Backup::Files do ...@@ -168,7 +168,7 @@ RSpec.describe Backup::Files do
it 'raises an error and outputs an error message if rsync failed' do it 'raises an error and outputs an error message if rsync failed' do
allow(Gitlab::Popen).to receive(:popen) allow(Gitlab::Popen).to receive(:popen)
.with(%w(rsync -a --delete --exclude=lost+found --exclude=/@pages.tmp /var/gitlab-pages /var/gitlab-backup)) .with(%w(rsync -a --delete --exclude=lost+found --exclude=/gitlab-pages/@pages.tmp /var/gitlab-pages /var/gitlab-backup))
.and_return(['rsync failed', 1]) .and_return(['rsync failed', 1])
expect do expect do
...@@ -186,8 +186,8 @@ RSpec.describe Backup::Files do ...@@ -186,8 +186,8 @@ RSpec.describe Backup::Files do
expect(subject.exclude_dirs(:tar)).to eq(['--exclude=lost+found', '--exclude=./@pages.tmp']) expect(subject.exclude_dirs(:tar)).to eq(['--exclude=lost+found', '--exclude=./@pages.tmp'])
end end
it 'prepends a leading slash to rsync excludes' do it 'prepends a leading slash and app_files_dir basename to rsync excludes' do
expect(subject.exclude_dirs(:rsync)).to eq(['--exclude=lost+found', '--exclude=/@pages.tmp']) expect(subject.exclude_dirs(:rsync)).to eq(['--exclude=lost+found', '--exclude=/gitlab-pages/@pages.tmp'])
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment