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
15daeb96
Commit
15daeb96
authored
Sep 18, 2020
by
James Fargher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy up backup/restore error handling
parent
eadde611
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
14 deletions
+10
-14
lib/backup/repositories.rb
lib/backup/repositories.rb
+8
-12
spec/lib/backup/repositories_spec.rb
spec/lib/backup/repositories_spec.rb
+2
-2
No files found.
lib/backup/repositories.rb
View file @
15daeb96
...
...
@@ -53,7 +53,7 @@ module Backup
private
def
restore_repository
(
container
,
type
)
BackupRestore
r
.
new
(
BackupRestore
.
new
(
progress
,
type
.
repository_for
(
container
),
backup_repos_path
...
...
@@ -121,7 +121,7 @@ module Backup
end
def
backup_repository
(
container
,
type
)
BackupRestore
r
.
new
(
BackupRestore
.
new
(
progress
,
type
.
repository_for
(
container
),
backup_repos_path
...
...
@@ -140,7 +140,7 @@ module Backup
end
end
class
BackupRestore
r
class
BackupRestore
attr_accessor
:progress
,
:repository
,
:backup_repos_path
def
initialize
(
progress
,
repository
,
backup_repos_path
)
...
...
@@ -165,7 +165,8 @@ module Backup
progress
.
puts
" *
#{
display_repo_path
}
... "
+
"[DONE]"
.
color
(
:green
)
rescue
=>
e
progress_warn
(
e
,
'Failed to backup repo'
)
progress
.
puts
"[Failed] backing up
#{
display_repo_path
}
"
.
color
(
:red
)
progress
.
puts
"Error
#{
e
}
"
.
color
(
:red
)
end
def
restore
(
always_create:
false
)
...
...
@@ -183,7 +184,8 @@ module Backup
progress
.
puts
" *
#{
display_repo_path
}
... "
+
"[DONE]"
.
color
(
:green
)
rescue
=>
e
progress_warn
(
e
,
'Failed to restore repo'
)
progress
.
puts
"[Failed] restoring
#{
display_repo_path
}
"
.
color
(
:red
)
progress
.
puts
"Error
#{
e
}
"
.
color
(
:red
)
end
private
...
...
@@ -201,8 +203,7 @@ module Backup
end
def
restore_custom_hooks
return
unless
Dir
.
exist?
(
repository_backup_path
)
return
if
Dir
.
glob
(
"
#{
repository_backup_path
}
/custom_hooks*"
).
none?
return
unless
File
.
exist?
(
custom_hooks_tar
)
repository
.
gitaly_repository_client
.
restore_custom_hooks
(
custom_hooks_tar
)
end
...
...
@@ -210,11 +211,6 @@ module Backup
def
custom_hooks_tar
File
.
join
(
repository_backup_path
,
"custom_hooks.tar"
)
end
def
progress_warn
(
cmd
,
output
)
progress
.
puts
"[WARNING] Executing
#{
cmd
}
"
.
color
(
:orange
)
progress
.
puts
"Ignoring error on
#{
display_repo_path
}
-
#{
output
}
"
.
color
(
:orange
)
end
end
class
InterlockSizedQueue
<
SizedQueue
...
...
spec/lib/backup/repositories_spec.rb
View file @
15daeb96
...
...
@@ -161,7 +161,7 @@ RSpec.describe Backup::Repositories do
it
'shows the appropriate error'
do
subject
.
restore
expect
(
progress
).
to
have_received
(
:puts
).
with
(
"
Ignoring error on
#{
project
.
full_path
}
(
#{
project
.
disk_path
}
) - Failed to restore repo
"
)
expect
(
progress
).
to
have_received
(
:puts
).
with
(
"
[Failed] restoring
#{
project
.
full_path
}
(
#{
project
.
disk_path
}
)
"
)
end
end
...
...
@@ -171,7 +171,7 @@ RSpec.describe Backup::Repositories do
it
'shows the appropriate error'
do
subject
.
restore
expect
(
progress
).
to
have_received
(
:puts
).
with
(
"
Ignoring error on
#{
project
.
full_path
}
(
#{
project
.
disk_path
}
) - Failed to restore repo
"
)
expect
(
progress
).
to
have_received
(
:puts
).
with
(
"
[Failed] restoring
#{
project
.
full_path
}
(
#{
project
.
disk_path
}
)
"
)
end
end
end
...
...
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