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
2bce8172
Commit
2bce8172
authored
Feb 17, 2020
by
Henrik Christian Grove
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring of the unpack function
parent
7b9b74cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
28 deletions
+28
-28
lib/backup/manager.rb
lib/backup/manager.rb
+27
-28
lib/tasks/gitlab/backup.rake
lib/tasks/gitlab/backup.rake
+1
-0
No files found.
lib/backup/manager.rb
View file @
2bce8172
...
@@ -107,10 +107,26 @@ module Backup
...
@@ -107,10 +107,26 @@ module Backup
end
end
end
end
# rubocop: disable Metrics/AbcSize
def
verify_restore
def
unpack
Dir
.
chdir
(
backup_path
)
do
cleanup_required
=
true
ENV
[
"VERSION"
]
=
"
#{
settings
[
:db_version
]
}
"
if
settings
[
:db_version
].
to_i
>
0
# restoring mismatching backups can lead to unexpected problems
if
settings
[
:gitlab_version
]
!=
Gitlab
::
VERSION
progress
.
puts
(
<<~
HEREDOC
.
color
(
:red
))
GitLab version mismatch:
Your current GitLab version (
#{
Gitlab
::
VERSION
}
) differs from the GitLab version in the backup!
Please switch to the following version and try again:
version:
#{
settings
[
:gitlab_version
]
}
HEREDOC
progress
.
puts
progress
.
puts
"Hint: git checkout v
#{
settings
[
:gitlab_version
]
}
"
exit
1
end
end
end
# rubocop: disable Cop/AvoidReturnFromBlocks
def
unpack
Dir
.
chdir
(
backup_path
)
do
Dir
.
chdir
(
backup_path
)
do
if
ENV
[
'BACKUP'
].
present?
if
ENV
[
'BACKUP'
].
present?
# User has indicated which backup to restore
# User has indicated which backup to restore
...
@@ -124,9 +140,8 @@ module Backup
...
@@ -124,9 +140,8 @@ module Backup
else
else
# check for existing backups in the backup dir
# check for existing backups in the backup dir
if
File
.
exist?
(
File
.
join
(
backup_path
,
'backup_information.yml'
))
if
File
.
exist?
(
File
.
join
(
backup_path
,
'backup_information.yml'
))
tar_file
=
'SKIP'
progress
.
puts
"Non tarred backup found in
#{
backup_path
}
, using that"
progress
.
puts
"Non tarred backup found in
#{
backup_path
}
, using that"
cleanup_required
=
false
return
false
elsif
backup_file_list
.
empty?
elsif
backup_file_list
.
empty?
progress
.
puts
"No backups found in
#{
backup_path
}
"
progress
.
puts
"No backups found in
#{
backup_path
}
"
progress
.
puts
"Please make sure that file name ends with
#{
FILE_NAME_SUFFIX
}
"
progress
.
puts
"Please make sure that file name ends with
#{
FILE_NAME_SUFFIX
}
"
...
@@ -143,7 +158,6 @@ module Backup
...
@@ -143,7 +158,6 @@ module Backup
end
end
end
end
unless
tar_file
==
'SKIP'
progress
.
print
'Unpacking backup ... '
progress
.
print
'Unpacking backup ... '
if
Kernel
.
system
(
*
%W(tar -xf
#{
tar_file
}
)
)
if
Kernel
.
system
(
*
%W(tar -xf
#{
tar_file
}
)
)
...
@@ -153,24 +167,9 @@ module Backup
...
@@ -153,24 +167,9 @@ module Backup
exit
1
exit
1
end
end
end
end
true
ENV
[
"VERSION"
]
=
"
#{
settings
[
:db_version
]
}
"
if
settings
[
:db_version
].
to_i
>
0
# restoring mismatching backups can lead to unexpected problems
if
settings
[
:gitlab_version
]
!=
Gitlab
::
VERSION
progress
.
puts
(
<<~
HEREDOC
.
color
(
:red
))
GitLab version mismatch:
Your current GitLab version (
#{
Gitlab
::
VERSION
}
) differs from the GitLab version in the backup!
Please switch to the following version and try again:
version:
#{
settings
[
:gitlab_version
]
}
HEREDOC
progress
.
puts
progress
.
puts
"Hint: git checkout v
#{
settings
[
:gitlab_version
]
}
"
exit
1
end
end
cleanup_required
end
end
# rubocop: enable Cop/AvoidReturnFromBlocks
def
tar_version
def
tar_version
tar_version
,
_
=
Gitlab
::
Popen
.
popen
(
%w(tar --version)
)
tar_version
,
_
=
Gitlab
::
Popen
.
popen
(
%w(tar --version)
)
...
...
lib/tasks/gitlab/backup.rake
View file @
2bce8172
...
@@ -41,6 +41,7 @@ namespace :gitlab do
...
@@ -41,6 +41,7 @@ namespace :gitlab do
backup
=
Backup
::
Manager
.
new
(
progress
)
backup
=
Backup
::
Manager
.
new
(
progress
)
cleanup_required
=
backup
.
unpack
cleanup_required
=
backup
.
unpack
backup
.
verify_restore
unless
backup
.
skipped?
(
'db'
)
unless
backup
.
skipped?
(
'db'
)
begin
begin
...
...
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