BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c085f88f
Commit
c085f88f
authored
Jun 07, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix backup task to ignore errors per project
parent
1b76c719
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
26 deletions
+29
-26
repository.rb
lib/backup/repository.rb
+29
-26
No files found.
lib/backup/repository.rb
View file @
c085f88f
...
@@ -14,7 +14,7 @@ module Backup
...
@@ -14,7 +14,7 @@ module Backup
# Create namespace dir if missing
# Create namespace dir if missing
FileUtils
.
mkdir_p
(
File
.
join
(
backup_repos_path
,
project
.
namespace
.
full_path
))
if
project
.
namespace
FileUtils
.
mkdir_p
(
File
.
join
(
backup_repos_path
,
project
.
namespace
.
full_path
))
if
project
.
namespace
if
project
.
empty_repo?
if
empty_repo?
(
project
)
$progress
.
puts
"[SKIPPED]"
.
color
(
:cyan
)
$progress
.
puts
"[SKIPPED]"
.
color
(
:cyan
)
else
else
in_path
(
path_to_project_repo
)
do
|
dir
|
in_path
(
path_to_project_repo
)
do
|
dir
|
...
@@ -23,10 +23,7 @@ module Backup
...
@@ -23,10 +23,7 @@ module Backup
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
unless
status
.
zero?
unless
status
.
zero?
puts
"[FAILED]"
.
color
(
:red
)
progress_warn
(
project
,
cmd
.
join
(
' '
),
output
)
puts
"failed:
#{
cmd
.
join
(
' '
)
}
"
puts
output
abort
'Backup failed'
end
end
end
end
...
@@ -36,10 +33,7 @@ module Backup
...
@@ -36,10 +33,7 @@ module Backup
if
status
.
zero?
if
status
.
zero?
$progress
.
puts
"[DONE]"
.
color
(
:green
)
$progress
.
puts
"[DONE]"
.
color
(
:green
)
else
else
puts
"[FAILED]"
.
color
(
:red
)
progress_warn
(
project
,
cmd
.
join
(
' '
),
output
)
puts
"failed:
#{
cmd
.
join
(
' '
)
}
"
puts
output
abort
'Backup failed'
end
end
end
end
...
@@ -49,7 +43,7 @@ module Backup
...
@@ -49,7 +43,7 @@ module Backup
if
File
.
exist?
(
path_to_wiki_repo
)
if
File
.
exist?
(
path_to_wiki_repo
)
$progress
.
print
" *
#{
wiki
.
path_with_namespace
}
... "
$progress
.
print
" *
#{
wiki
.
path_with_namespace
}
... "
if
wiki
.
repository
.
empty?
if
empty_wiki_repo?
(
wiki
)
$progress
.
puts
" [SKIPPED]"
.
color
(
:cyan
)
$progress
.
puts
" [SKIPPED]"
.
color
(
:cyan
)
else
else
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path_to_wiki_repo
}
bundle create
#{
path_to_wiki_bundle
}
--all)
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path_to_wiki_repo
}
bundle create
#{
path_to_wiki_bundle
}
--all)
...
@@ -57,10 +51,7 @@ module Backup
...
@@ -57,10 +51,7 @@ module Backup
if
status
.
zero?
if
status
.
zero?
$progress
.
puts
" [DONE]"
.
color
(
:green
)
$progress
.
puts
" [DONE]"
.
color
(
:green
)
else
else
puts
" [FAILED]"
.
color
(
:red
)
progress_warn
(
wiki
,
cmd
.
join
(
' '
),
output
)
puts
"failed:
#{
cmd
.
join
(
' '
)
}
"
puts
output
abort
'Backup failed'
end
end
end
end
end
end
...
@@ -96,10 +87,7 @@ module Backup
...
@@ -96,10 +87,7 @@ module Backup
if
status
.
zero?
if
status
.
zero?
$progress
.
puts
"[DONE]"
.
color
(
:green
)
$progress
.
puts
"[DONE]"
.
color
(
:green
)
else
else
puts
"[FAILED]"
.
color
(
:red
)
progress_warn
(
project
,
cmd
.
join
(
' '
),
output
)
puts
"failed:
#{
cmd
.
join
(
' '
)
}
"
puts
output
abort
'Restore failed'
end
end
in_path
(
path_to_tars
(
project
))
do
|
dir
|
in_path
(
path_to_tars
(
project
))
do
|
dir
|
...
@@ -107,10 +95,7 @@ module Backup
...
@@ -107,10 +95,7 @@ module Backup
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
unless
status
.
zero?
unless
status
.
zero?
puts
"[FAILED]"
.
color
(
:red
)
progress_warn
(
project
,
cmd
.
join
(
' '
),
output
)
puts
"failed:
#{
cmd
.
join
(
' '
)
}
"
puts
output
abort
'Restore failed'
end
end
end
end
...
@@ -131,10 +116,7 @@ module Backup
...
@@ -131,10 +116,7 @@ module Backup
if
status
.
zero?
if
status
.
zero?
$progress
.
puts
" [DONE]"
.
color
(
:green
)
$progress
.
puts
" [DONE]"
.
color
(
:green
)
else
else
puts
" [FAILED]"
.
color
(
:red
)
progress_warn
(
project
,
cmd
.
join
(
' '
),
output
)
puts
"failed:
#{
cmd
.
join
(
' '
)
}
"
puts
output
abort
'Restore failed'
end
end
end
end
end
end
...
@@ -201,6 +183,27 @@ module Backup
...
@@ -201,6 +183,27 @@ module Backup
private
private
def
progress_warn
(
project
,
cmd
,
output
)
$progress
.
puts
"[WARNING] Executing
#{
cmd
}
"
.
color
(
:orange
)
$progress
.
puts
"Ignoring error on
#{
project
.
path_with_namespace
}
-
#{
output
}
"
.
color
(
:orange
)
end
def
empty_repo?
(
project
)
project
.
empty_repo?
rescue
=>
e
$progress
.
puts
"Ignoring error on
#{
project
.
full_path
}
repository -
#{
e
.
message
}
"
.
color
(
:orange
)
false
end
def
empty_wiki_repo?
(
wiki
)
wiki
.
repository
.
empty?
rescue
=>
e
$progress
.
puts
"Ignoring error on
#{
wiki
.
path_with_namespace
}
repository -
#{
e
.
message
}
"
.
color
(
:orange
)
false
end
def
repository_storage_paths_args
def
repository_storage_paths_args
Gitlab
.
config
.
repositories
.
storages
.
values
.
map
{
|
rs
|
rs
[
'path'
]
}
Gitlab
.
config
.
repositories
.
storages
.
values
.
map
{
|
rs
|
rs
[
'path'
]
}
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