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
80197bdc
Commit
80197bdc
authored
May 21, 2018
by
Ahmad Hassan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove gitaly_migrate blocks and replace by early return
parent
125be186
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
33 deletions
+26
-33
lib/backup/repository.rb
lib/backup/repository.rb
+26
-33
No files found.
lib/backup/repository.rb
View file @
80197bdc
...
@@ -67,48 +67,41 @@ module Backup
...
@@ -67,48 +67,41 @@ module Backup
end
end
def
prepare_directories
def
prepare_directories
# TODO: Need to find a way to do this for gitaly
# Gitaly discussion issue: https://gitlab.com/gitlab-org/gitaly/issues/1194
return
if
Gitlab
::
GitalyClient
.
feature_enabled?
(
:backup_skip_prepare_directories
)
return
if
Gitlab
::
GitalyClient
.
feature_enabled?
(
:backup_skip_prepare_directories
)
Gitlab
.
config
.
repositories
.
storages
.
each
do
|
name
,
repository_storage
|
Gitlab
.
config
.
repositories
.
storages
.
each
do
|
name
,
repository_storage
|
gitaly_migrate
(
:remove_repositories
)
do
|
is_enabled
|
path
=
repository_storage
.
legacy_disk_path
# TODO: Need to find a way to do this for gitaly
next
unless
File
.
exist?
(
path
)
# Gitaly discussion issue: https://gitlab.com/gitlab-org/gitaly/issues/1194
unless
is_enabled
# Move all files in the existing repos directory except . and .. to
path
=
repository_storage
.
legacy_disk_path
# repositories.old.<timestamp> directory
next
unless
File
.
exist?
(
path
)
bk_repos_path
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"tmp"
,
"
#{
name
}
-repositories.old."
+
Time
.
now
.
to_i
.
to_s
)
FileUtils
.
mkdir_p
(
bk_repos_path
,
mode:
0700
)
# Move all files in the existing repos directory except . and .. to
files
=
Dir
.
glob
(
File
.
join
(
path
,
"*"
),
File
::
FNM_DOTMATCH
)
-
[
File
.
join
(
path
,
"."
),
File
.
join
(
path
,
".."
)]
# repositories.old.<timestamp> directory
bk_repos_path
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"tmp"
,
"
#{
name
}
-repositories.old."
+
Time
.
now
.
to_i
.
to_s
)
begin
FileUtils
.
mkdir_p
(
bk_repos_path
,
mode:
0700
)
FileUtils
.
mv
(
files
,
bk_repos_path
)
files
=
Dir
.
glob
(
File
.
join
(
path
,
"*"
),
File
::
FNM_DOTMATCH
)
-
[
File
.
join
(
path
,
"."
),
File
.
join
(
path
,
".."
)]
rescue
Errno
::
EACCES
access_denied_error
(
path
)
begin
rescue
Errno
::
EBUSY
FileUtils
.
mv
(
files
,
bk_repos_path
)
resource_busy_error
(
path
)
rescue
Errno
::
EACCES
access_denied_error
(
path
)
rescue
Errno
::
EBUSY
resource_busy_error
(
path
)
end
end
end
end
end
end
end
end
def
restore_custom_hooks
def
restore_custom_hooks
gitaly_migrate
(
:restore_custom_hooks
)
do
|
is_enabled
|
# TODO: Need to find a way to do this for gitaly
# TODO: Need to find a way to do this for gitaly
# Gitaly migration issue: https://gitlab.com/gitlab-org/gitaly/issues/1195
# Gitaly migration issue: https://gitlab.com/gitlab-org/gitaly/issues/1195
in_path
(
path_to_tars
(
project
))
do
|
dir
|
unless
is_enabled
path_to_project_repo
=
path_to_repo
(
project
)
in_path
(
path_to_tars
(
project
))
do
|
dir
|
cmd
=
%W(tar -xf
#{
path_to_tars
(
project
,
dir
)
}
-C
#{
path_to_project_repo
}
#{
dir
}
)
path_to_project_repo
=
path_to_repo
(
project
)
cmd
=
%W(tar -xf
#{
path_to_tars
(
project
,
dir
)
}
-C
#{
path_to_project_repo
}
#{
dir
}
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
unless
status
.
zero?
unless
status
.
zero?
progress_warn
(
project
,
cmd
.
join
(
' '
),
output
)
progress_warn
(
project
,
cmd
.
join
(
' '
),
output
)
end
end
end
end
end
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