diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /lib/backup | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'lib/backup')
-rw-r--r-- | lib/backup/repositories.rb | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/lib/backup/repositories.rb b/lib/backup/repositories.rb index 4248a86dc7c..d15114a72a3 100644 --- a/lib/backup/repositories.rb +++ b/lib/backup/repositories.rb @@ -40,31 +40,42 @@ module Backup end def restore + restore_project_repositories + restore_snippets + + restore_object_pools + end + + private + + def restore_project_repositories 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 + end + def restore_snippets invalid_ids = Snippet.find_each(batch_size: 1000) .map { |snippet| restore_snippet_repository(snippet) } .compact cleanup_snippets_without_repositories(invalid_ids) - - restore_object_pools end - private - def check_valid_storages! - [ProjectRepository, SnippetRepository].each do |klass| + repository_storage_klasses.each do |klass| if klass.excluding_repository_storage(Gitlab.config.repositories.storages.keys).exists? raise Error, "repositories.storages in gitlab.yml does not include all storages used by #{klass}" end end end + def repository_storage_klasses + [ProjectRepository, SnippetRepository] + end + def backup_repos_path @backup_repos_path ||= File.join(Gitlab.config.backup.path, 'repositories') end @@ -103,12 +114,7 @@ module Backup end begin - case container - when Project - dump_project(container) - when Snippet - dump_snippet(container) - end + dump_container(container) rescue => e errors << e break @@ -130,6 +136,15 @@ module Backup end end + def dump_container(container) + case container + when Project + dump_project(container) + when Snippet + dump_snippet(container) + end + end + def dump_project(project) backup_repository(project, Gitlab::GlRepository::PROJECT) backup_repository(project, Gitlab::GlRepository::WIKI) @@ -308,3 +323,5 @@ module Backup end end end + +Backup::Repositories.prepend_if_ee('EE::Backup::Repositories') |