diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-16 12:09:12 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-16 12:09:12 +0000 |
commit | cbfe03ae04a52d9825ff7cbeccdfe5d313adf6a2 (patch) | |
tree | e4879b35d019d3bbba1689f3ac4c48b81bf7b451 /lib/backup | |
parent | 3fd97b4bba24ca412112aad025a38a32c7a6cf8c (diff) | |
download | gitlab-ce-cbfe03ae04a52d9825ff7cbeccdfe5d313adf6a2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/backup')
-rw-r--r-- | lib/backup/repository.rb | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 123a695be13..1c5108b12ab 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -4,7 +4,6 @@ require 'yaml' module Backup class Repository - include Gitlab::ShellAdapter attr_reader :progress def initialize(progress) @@ -71,23 +70,14 @@ module Backup def restore Project.find_each(batch_size: 1000) do |project| progress.print " * #{project.full_path} ... " - path_to_project_bundle = path_to_bundle(project) - project.repository.remove rescue nil - restore_repo_success = nil - - if File.exist?(path_to_project_bundle) + restore_repo_success = begin - project.repository.create_from_bundle(path_to_project_bundle) - restore_custom_hooks(project) - restore_repo_success = true - rescue => e - restore_repo_success = false - progress.puts "Error: #{e}".color(:red) + try_restore_repository(project) + rescue => err + progress.puts "Error: #{err}".color(:red) + false end - else - restore_repo_success = gitlab_shell.create_project_repository(project) - end if restore_repo_success progress.puts "[DONE]".color(:green) @@ -118,6 +108,20 @@ module Backup protected + def try_restore_repository(project) + path_to_project_bundle = path_to_bundle(project) + project.repository.remove rescue nil + + if File.exist?(path_to_project_bundle) + project.repository.create_from_bundle(path_to_project_bundle) + restore_custom_hooks(project) + else + project.repository.create_repository + end + + true + end + def path_to_bundle(project) File.join(backup_repos_path, project.disk_path + '.bundle') end |