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
12bd7810
Commit
12bd7810
authored
May 23, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix backups if registry is disabled
parent
3c18a4f8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
8 deletions
+43
-8
lib/backup/manager.rb
lib/backup/manager.rb
+11
-2
lib/tasks/gitlab/backup.rake
lib/tasks/gitlab/backup.rake
+14
-6
spec/tasks/gitlab/backup_rake_spec.rb
spec/tasks/gitlab/backup_rake_spec.rb
+18
-0
No files found.
lib/backup/manager.rb
View file @
12bd7810
module
Backup
class
Manager
ARCHIVES_TO_BACKUP
=
%w{uploads builds artifacts lfs registry}
FOLDERS_TO_BACKUP
=
%w{repositories db}
def
pack
# Make sure there is a connection
ActiveRecord
::
Base
.
connection
.
reconnect!
...
...
@@ -157,11 +160,17 @@ module Backup
end
def
archives_to_backup
%w{uploads builds artifacts lfs registry}
.
map
{
|
name
|
(
name
+
".tar.gz"
)
unless
skipped?
(
name
)
}.
compact
(
ARCHIVES_TO_BACKUP
-
disabled_features
)
.
map
{
|
name
|
(
name
+
".tar.gz"
)
unless
skipped?
(
name
)
}.
compact
end
def
folders_to_backup
%w{repositories db}
.
reject
{
|
name
|
skipped?
(
name
)
}
(
FOLDERS_TO_BACKUP
-
disabled_features
).
reject
{
|
name
|
skipped?
(
name
)
}
end
def
disabled_features
features
=
[]
features
<<
'registry'
unless
Gitlab
.
config
.
registry
.
enabled
features
end
def
settings
...
...
lib/tasks/gitlab/backup.rake
View file @
12bd7810
...
...
@@ -179,18 +179,26 @@ namespace :gitlab do
task
create: :environment
do
$progress
.
puts
"Dumping container registry images ... "
.
blue
if
Gitlab
.
config
.
registry
.
enabled
if
ENV
[
"SKIP"
]
&&
ENV
[
"SKIP"
].
include?
(
"registry"
)
$progress
.
puts
"[SKIPPED]"
.
cyan
else
Backup
::
Registry
.
new
.
dump
$progress
.
puts
"done"
.
green
end
else
$progress
.
puts
"[DISABLED]"
.
cyan
end
end
task
restore: :environment
do
$progress
.
puts
"Restoring container registry images ... "
.
blue
if
Gitlab
.
config
.
registry
.
enabled
Backup
::
Registry
.
new
.
restore
$progress
.
puts
"done"
.
green
else
$progress
.
puts
"[DISABLED]"
.
cyan
end
end
end
...
...
spec/tasks/gitlab/backup_rake_spec.rb
View file @
12bd7810
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
'rake'
describe
'gitlab:app namespace rake task'
do
let
(
:enable_registry
)
{
true
}
before
:all
do
Rake
.
application
.
rake_require
'tasks/gitlab/task_helpers'
Rake
.
application
.
rake_require
'tasks/gitlab/backup'
...
...
@@ -15,6 +17,10 @@ describe 'gitlab:app namespace rake task' do
FileUtils
.
mkdir_p
(
'public/uploads'
)
end
before
do
stub_container_registry_config
(
enabled:
enable_registry
)
end
def
run_rake_task
(
task_name
)
Rake
::
Task
[
task_name
].
reenable
Rake
.
application
.
invoke_task
task_name
...
...
@@ -143,6 +149,18 @@ describe 'gitlab:app namespace rake task' do
expect
(
temp_dirs
).
to
be_empty
end
context
'registry disabled'
do
let
(
:enable_registry
)
{
false
}
it
'should not create registry.tar.gz'
do
tar_contents
,
exit_status
=
Gitlab
::
Popen
.
popen
(
%W{tar -tvf
#{
@backup_tar
}
}
)
expect
(
exit_status
).
to
eq
(
0
)
expect
(
tar_contents
).
not_to
match
(
'registry.tar.gz'
)
end
end
end
# backup_create task
describe
"Skipping items"
do
...
...
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