From 89a407dc3bea38b60e06eb825991cbea0c87b85a Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Mon, 10 Dec 2018 09:31:28 +0100 Subject: Restore Object Pools when restoring an object pool Pool repositories are persisted in the database, and when the DB is restored, the data need to be restored on disk. This is done by resetting the state machine and rescheduling the object pool creation. This is not an exact replica of the state like at the time of the creation of the backup. However, the data is consistent again. Dumping isn't required as internally GitLab uses git bundles which bundle all refs and include all objects in the bundle that they require, reduplicating as more repositories get backed up. This does require more data to be stored. Fixes https://gitlab.com/gitlab-org/gitaly/issues/1355 --- lib/backup/repository.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index c8a5377bfa0..184c7418e75 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -4,6 +4,7 @@ require 'yaml' module Backup class Repository + include Gitlab::ShellAdapter attr_reader :progress def initialize(progress) @@ -75,7 +76,6 @@ module Backup def restore prepare_directories - gitlab_shell = Gitlab::Shell.new Project.find_each(batch_size: 1000) do |project| progress.print " * #{project.full_path} ... " @@ -118,6 +118,8 @@ module Backup end end end + + restore_object_pools end protected @@ -159,5 +161,17 @@ module Backup def display_repo_path(project) project.hashed_storage?(:repository) ? "#{project.full_path} (#{project.disk_path})" : project.full_path end + + def restore_object_pools + PoolRepository.includes(:source_project).find_each do |pool| + progress.puts " - Object pool #{pool.disk_path}..." + + pool.source_project ||= pool.member_projects.first.root_of_fork_network + pool.state = 'none' + pool.save + + pool.schedule + end + end end end -- cgit v1.2.3