Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a54f011e
Commit
a54f011e
authored
Dec 13, 2020
by
Adam Mulvany
Committed by
Thong Kuah
Dec 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Retry rsync when source files vanish during backup
parent
40a8cdb0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
changelogs/unreleased/am-modifying-files-rb-to-retry-on-rsync-error.yml
...eleased/am-modifying-files-rb-to-retry-on-rsync-error.yml
+5
-0
lib/backup/files.rb
lib/backup/files.rb
+7
-1
spec/lib/backup/files_spec.rb
spec/lib/backup/files_spec.rb
+16
-2
No files found.
changelogs/unreleased/am-modifying-files-rb-to-retry-on-rsync-error.yml
0 → 100644
View file @
a54f011e
---
title
:
Retry rsync when source files vanish during backup
merge_request
:
48568
author
:
type
:
added
lib/backup/files.rb
View file @
a54f011e
...
@@ -26,9 +26,15 @@ module Backup
...
@@ -26,9 +26,15 @@ module Backup
FileUtils
.
rm_f
(
backup_tarball
)
FileUtils
.
rm_f
(
backup_tarball
)
if
ENV
[
'STRATEGY'
]
==
'copy'
if
ENV
[
'STRATEGY'
]
==
'copy'
cmd
=
[
%w[rsync -a]
,
exclude_dirs
(
:rsync
),
%W[
#{
app_files_dir
}
#{
Gitlab
.
config
.
backup
.
path
}
]
].
flatten
cmd
=
[
%w[rsync -a
--delete
]
,
exclude_dirs
(
:rsync
),
%W[
#{
app_files_dir
}
#{
Gitlab
.
config
.
backup
.
path
}
]
].
flatten
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
# Retry if rsync source files vanish
if
status
==
24
$stdout
.
puts
"Warning: files vanished during rsync, retrying..."
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
end
unless
status
==
0
unless
status
==
0
puts
output
puts
output
raise
Backup
::
Error
,
'Backup failed'
raise
Backup
::
Error
,
'Backup failed'
...
...
spec/lib/backup/files_spec.rb
View file @
a54f011e
...
@@ -149,13 +149,27 @@ RSpec.describe Backup::Files do
...
@@ -149,13 +149,27 @@ RSpec.describe Backup::Files do
end
end
it
'excludes tmp dirs from rsync'
do
it
'excludes tmp dirs from rsync'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
).
with
(
%w(rsync -a --exclude=lost+found --exclude=/@pages.tmp /var/gitlab-pages /var/gitlab-backup)
).
and_return
([
''
,
0
])
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
(
%w(rsync -a --delete --exclude=lost+found --exclude=/@pages.tmp /var/gitlab-pages /var/gitlab-backup)
)
.
and_return
([
''
,
0
])
subject
.
dump
subject
.
dump
end
end
it
'retries if rsync fails due to vanishing files'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
(
%w(rsync -a --delete --exclude=lost+found --exclude=/@pages.tmp /var/gitlab-pages /var/gitlab-backup)
)
.
and_return
([
'rsync failed'
,
24
],
[
''
,
0
])
expect
do
subject
.
dump
end
.
to
output
(
/files vanished during rsync, retrying/
).
to_stdout
end
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
).
with
(
%w(rsync -a --exclude=lost+found --exclude=/@pages.tmp /var/gitlab-pages /var/gitlab-backup)
).
and_return
([
'rsync failed'
,
1
])
allow
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
(
%w(rsync -a --delete --exclude=lost+found --exclude=/@pages.tmp /var/gitlab-pages /var/gitlab-backup)
)
.
and_return
([
'rsync failed'
,
1
])
expect
do
expect
do
subject
.
dump
subject
.
dump
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment