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
567baf0e
Commit
567baf0e
authored
Oct 10, 2017
by
Rémy Coutable
Committed by
Winnie Hellmann
Oct 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stub ENV in the backup task spec file
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
be2c6657
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
43 deletions
+39
-43
manager.rb
lib/backup/manager.rb
+39
-39
manager_spec.rb
spec/lib/gitlab/backup/manager_spec.rb
+0
-4
backup_rake_spec.rb
spec/tasks/gitlab/backup_rake_spec.rb
+0
-0
No files found.
lib/backup/manager.rb
View file @
567baf0e
...
@@ -101,50 +101,50 @@ module Backup
...
@@ -101,50 +101,50 @@ module Backup
end
end
def
unpack
def
unpack
Dir
.
chdir
(
backup_path
)
Dir
.
chdir
(
backup_path
)
do
# check for existing backups in the backup dir
# check for existing backups in the backup dir
if
backup_file_list
.
empty?
if
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
}
"
exit
1
exit
1
elsif
backup_file_list
.
many?
&&
ENV
[
"BACKUP"
].
nil?
elsif
backup_file_list
.
many?
&&
ENV
[
"BACKUP"
].
nil?
$progress
.
puts
'Found more than one backup, please specify which one you want to restore:'
$progress
.
puts
'Found more than one backup, please specify which one you want to restore:'
$progress
.
puts
'rake gitlab:backup:restore BACKUP=timestamp_of_backup'
$progress
.
puts
'rake gitlab:backup:restore BACKUP=timestamp_of_backup'
exit
1
exit
1
end
end
tar_file
=
if
ENV
[
'BACKUP'
].
present?
tar_file
=
if
ENV
[
'BACKUP'
].
present?
"
#{
ENV
[
'BACKUP'
]
}#{
FILE_NAME_SUFFIX
}
"
"
#{
ENV
[
'BACKUP'
]
}#{
FILE_NAME_SUFFIX
}
"
else
else
backup_file_list
.
first
backup_file_list
.
first
end
end
unless
File
.
exist?
(
tar_file
)
unless
File
.
exist?
(
tar_file
)
$progress
.
puts
"The backup file
#{
tar_file
}
does not exist!"
$progress
.
puts
"The backup file
#{
tar_file
}
does not exist!"
exit
1
exit
1
end
end
$progress
.
print
'Unpacking backup ... '
$progress
.
print
'Unpacking backup ... '
unless
Kernel
.
system
(
*
%W(tar -xf
#{
tar_file
}
)
)
unless
Kernel
.
system
(
*
%W(tar -xf
#{
tar_file
}
)
)
$progress
.
puts
'unpacking backup failed'
.
color
(
:red
)
$progress
.
puts
'unpacking backup failed'
.
color
(
:red
)
exit
1
exit
1
else
else
$progress
.
puts
'done'
.
color
(
:green
)
$progress
.
puts
'done'
.
color
(
:green
)
end
end
ENV
[
"VERSION"
]
=
"
#{
settings
[
:db_version
]
}
"
if
settings
[
:db_version
].
to_i
>
0
ENV
[
"VERSION"
]
=
"
#{
settings
[
:db_version
]
}
"
if
settings
[
:db_version
].
to_i
>
0
# restoring mismatching backups can lead to unexpected problems
# restoring mismatching backups can lead to unexpected problems
if
settings
[
:gitlab_version
]
!=
Gitlab
::
VERSION
if
settings
[
:gitlab_version
]
!=
Gitlab
::
VERSION
$progress
.
puts
'GitLab version mismatch:'
.
color
(
:red
)
$progress
.
puts
'GitLab version mismatch:'
.
color
(
:red
)
$progress
.
puts
" Your current GitLab version (
#{
Gitlab
::
VERSION
}
) differs from the GitLab version in the backup!"
.
color
(
:red
)
$progress
.
puts
" Your current GitLab version (
#{
Gitlab
::
VERSION
}
) differs from the GitLab version in the backup!"
.
color
(
:red
)
$progress
.
puts
' Please switch to the following version and try again:'
.
color
(
:red
)
$progress
.
puts
' Please switch to the following version and try again:'
.
color
(
:red
)
$progress
.
puts
" version:
#{
settings
[
:gitlab_version
]
}
"
.
color
(
:red
)
$progress
.
puts
" version:
#{
settings
[
:gitlab_version
]
}
"
.
color
(
:red
)
$progress
.
puts
$progress
.
puts
$progress
.
puts
"Hint: git checkout v
#{
settings
[
:gitlab_version
]
}
"
$progress
.
puts
"Hint: git checkout v
#{
settings
[
:gitlab_version
]
}
"
exit
1
exit
1
end
end
end
end
end
...
...
spec/lib/gitlab/backup/manager_spec.rb
View file @
567baf0e
...
@@ -172,10 +172,6 @@ describe Backup::Manager do
...
@@ -172,10 +172,6 @@ describe Backup::Manager do
end
end
describe
'#unpack'
do
describe
'#unpack'
do
before
do
allow
(
Dir
).
to
receive
(
:chdir
)
end
context
'when there are no backup files in the directory'
do
context
'when there are no backup files in the directory'
do
before
do
before
do
allow
(
Dir
).
to
receive
(
:glob
).
and_return
([])
allow
(
Dir
).
to
receive
(
:glob
).
and_return
([])
...
...
spec/tasks/gitlab/backup_rake_spec.rb
View file @
567baf0e
This diff is collapsed.
Click to expand it.
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