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
b0127668
Commit
b0127668
authored
Oct 02, 2020
by
Luke Duncalfe
Committed by
Bob Van Landuyt
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include design repositories in GitLab backup
https://gitlab.com/gitlab-org/gitlab/-/issues/233430
parent
f6ba3d41
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
3 deletions
+22
-3
changelogs/unreleased/233430-design-repo-in-backup.yml
changelogs/unreleased/233430-design-repo-in-backup.yml
+5
-0
lib/backup/repositories.rb
lib/backup/repositories.rb
+2
-0
spec/factories/design_management/designs.rb
spec/factories/design_management/designs.rb
+1
-1
spec/fixtures/lib/backup/design_repo.bundle
spec/fixtures/lib/backup/design_repo.bundle
+0
-0
spec/lib/backup/repositories_spec.rb
spec/lib/backup/repositories_spec.rb
+12
-2
spec/tasks/gitlab/backup_rake_spec.rb
spec/tasks/gitlab/backup_rake_spec.rb
+2
-0
No files found.
changelogs/unreleased/233430-design-repo-in-backup.yml
0 → 100644
View file @
b0127668
---
title
:
Include Design Management git repositories in GitLab Backup
merge_request
:
43947
author
:
type
:
fixed
lib/backup/repositories.rb
View file @
b0127668
...
...
@@ -45,6 +45,7 @@ module Backup
Project
.
find_each
(
batch_size:
1000
)
do
|
project
|
restore_repository
(
project
,
Gitlab
::
GlRepository
::
PROJECT
)
restore_repository
(
project
,
Gitlab
::
GlRepository
::
WIKI
)
restore_repository
(
project
,
Gitlab
::
GlRepository
::
DESIGN
)
end
restore_object_pools
...
...
@@ -118,6 +119,7 @@ module Backup
def
dump_project
(
project
)
backup_repository
(
project
,
Gitlab
::
GlRepository
::
PROJECT
)
backup_repository
(
project
,
Gitlab
::
GlRepository
::
WIKI
)
backup_repository
(
project
,
Gitlab
::
GlRepository
::
DESIGN
)
end
def
backup_repository
(
container
,
type
)
...
...
spec/factories/design_management/designs.rb
View file @
b0127668
...
...
@@ -75,7 +75,7 @@ FactoryBot.define do
end
# Use this trait if you want versions in a particular history, but don't
# want to pay for git
la
y calls.
# want to pay for git
al
y calls.
trait
:with_versions
do
transient
do
deleted
{
false
}
...
...
spec/fixtures/lib/backup/design_repo.bundle
0 → 100644
View file @
b0127668
File added
spec/lib/backup/repositories_spec.rb
View file @
b0127668
...
...
@@ -21,13 +21,15 @@ RSpec.describe Backup::Repositories do
RSpec
.
shared_examples
'creates repository bundles'
do
specify
:aggregate_failures
do
# Add data to the wiki
repository, so it
will be included in the dump.
# Add data to the wiki
and design repositories, so they
will be included in the dump.
create
(
:wiki_page
,
container:
project
)
create
(
:design
,
:with_file
,
issue:
create
(
:issue
,
project:
project
))
subject
.
dump
(
max_concurrency:
1
,
max_storage_concurrency:
1
)
expect
(
File
).
to
exist
(
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
'repositories'
,
project
.
disk_path
+
'.bundle'
))
expect
(
File
).
to
exist
(
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
'repositories'
,
project
.
disk_path
+
'.wiki'
+
'.bundle'
))
expect
(
File
).
to
exist
(
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
'repositories'
,
project
.
disk_path
+
'.design'
+
'.bundle'
))
end
end
...
...
@@ -157,7 +159,8 @@ RSpec.describe Backup::Repositories do
it
'restores repositories from bundles'
,
:aggregate_failures
do
next_path_to_bundle
=
[
Rails
.
root
.
join
(
'spec/fixtures/lib/backup/project_repo.bundle'
),
Rails
.
root
.
join
(
'spec/fixtures/lib/backup/wiki_repo.bundle'
)
Rails
.
root
.
join
(
'spec/fixtures/lib/backup/wiki_repo.bundle'
),
Rails
.
root
.
join
(
'spec/fixtures/lib/backup/design_repo.bundle'
)
].
to_enum
allow_next_instance_of
(
described_class
::
BackupRestore
)
do
|
backup_restore
|
...
...
@@ -170,12 +173,16 @@ RSpec.describe Backup::Repositories do
expect
(
collect_commit_shas
.
call
(
project
.
repository
)).
to
eq
([
'393a7d860a5a4c3cc736d7eb00604e3472bb95ec'
])
expect
(
collect_commit_shas
.
call
(
project
.
wiki
.
repository
)).
to
eq
([
'c74b9948d0088d703ee1fafeddd9ed9add2901ea'
])
expect
(
collect_commit_shas
.
call
(
project
.
design_repository
)).
to
eq
([
'c3cd4d7bd73a51a0f22045c3a4c871c435dc959d'
])
end
describe
'command failure'
do
before
do
expect
(
Project
).
to
receive
(
:find_each
).
and_yield
(
project
)
allow_next_instance_of
(
DesignManagement
::
Repository
)
do
|
repository
|
allow
(
repository
).
to
receive
(
:create_repository
)
{
raise
'Fail in tests'
}
end
allow_next_instance_of
(
Repository
)
do
|
repository
|
allow
(
repository
).
to
receive
(
:create_repository
)
{
raise
'Fail in tests'
}
end
...
...
@@ -214,6 +221,9 @@ RSpec.describe Backup::Repositories do
end
it
'cleans existing repositories'
do
expect_next_instance_of
(
DesignManagement
::
Repository
)
do
|
repository
|
expect
(
repository
).
to
receive
(
:remove
)
end
expect
(
Repository
).
to
receive
(
:new
).
twice
.
and_wrap_original
do
|
method
,
*
original_args
|
repository
=
method
.
call
(
*
original_args
)
...
...
spec/tasks/gitlab/backup_rake_spec.rb
View file @
b0127668
...
...
@@ -326,6 +326,7 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
let!
(
:project_a
)
{
create
(
:project
,
:repository
)
}
let!
(
:project_a_wiki_page
)
{
create
(
:wiki_page
,
container:
project_a
)
}
let!
(
:project_a_design
)
{
create
(
:design
,
:with_file
,
issue:
create
(
:issue
,
project:
project_a
))
}
let!
(
:project_b
)
{
create
(
:project
,
:repository
,
repository_storage:
'test_second_storage'
)
}
let!
(
:b_storage_dir
)
{
File
.
join
(
test_second_storage_dir
,
File
.
dirname
(
project_b
.
disk_path
))
}
...
...
@@ -341,6 +342,7 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
expect
(
tar_contents
).
to
include
(
"repositories/
#{
project_a
.
disk_path
}
.bundle"
,
"repositories/
#{
project_a
.
disk_path
}
.wiki.bundle"
,
"repositories/
#{
project_a
.
disk_path
}
.design.bundle"
,
"repositories/
#{
project_b
.
disk_path
}
.bundle"
)
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