Commit 5308b51e authored by Ahmad Hassan's avatar Ahmad Hassan

Output done for wiki and repo

parent 69de7b42
...@@ -4,7 +4,6 @@ require_relative 'helper' ...@@ -4,7 +4,6 @@ require_relative 'helper'
module Backup module Backup
class Repository class Repository
include Backup::Helper include Backup::Helper
# rubocop:disable Metrics/AbcSize
attr_reader :progress attr_reader :progress
...@@ -16,7 +15,6 @@ module Backup ...@@ -16,7 +15,6 @@ module Backup
prepare prepare
Project.find_each(batch_size: 1000) do |project| Project.find_each(batch_size: 1000) do |project|
# Create namespace dir or hashed path if missing
progress.print " * #{display_repo_path(project)} ... " progress.print " * #{display_repo_path(project)} ... "
if project.hashed_storage?(:repository) if project.hashed_storage?(:repository)
...@@ -27,22 +25,19 @@ module Backup ...@@ -27,22 +25,19 @@ module Backup
if !empty_repo?(project) if !empty_repo?(project)
backup_project(project) backup_project(project)
progress.puts "[DONE]".color(:green)
else else
progress.puts "[SKIPPED]".color(:cyan) progress.puts "[SKIPPED]".color(:cyan)
end end
wiki = ProjectWiki.new(project) wiki = ProjectWiki.new(project)
path_to_wiki_repo = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
path_to_repo(wiki)
end
if File.exist?(path_to_wiki_repo) && !empty_repo?(wiki) if !empty_repo?(wiki)
backup_project(wiki) backup_project(wiki)
progress.puts "[DONE] Wiki".color(:green)
else else
progress.puts "[SKIPPED] Wiki".color(:cyan) progress.puts "[SKIPPED] Wiki".color(:cyan)
end end
progress.puts "[DONE]".color(:green)
end end
end end
...@@ -100,8 +95,6 @@ module Backup ...@@ -100,8 +95,6 @@ module Backup
path = repository_storage.legacy_disk_path path = repository_storage.legacy_disk_path
return unless File.exist?(path) return unless File.exist?(path)
# Move all files in the existing repos directory except . and .. to
# repositories.old.<timestamp> directory
bk_repos_path = File.join(Gitlab.config.backup.path, "tmp", "#{name}-repositories.old." + Time.now.to_i.to_s) bk_repos_path = File.join(Gitlab.config.backup.path, "tmp", "#{name}-repositories.old." + Time.now.to_i.to_s)
FileUtils.mkdir_p(bk_repos_path, mode: 0700) FileUtils.mkdir_p(bk_repos_path, mode: 0700)
files = Dir.glob(File.join(path, "*"), File::FNM_DOTMATCH) - [File.join(path, "."), File.join(path, "..")] files = Dir.glob(File.join(path, "*"), File::FNM_DOTMATCH) - [File.join(path, "."), File.join(path, "..")]
...@@ -223,7 +216,6 @@ module Backup ...@@ -223,7 +216,6 @@ module Backup
end end
end end
end end
# rubocop:enable Metrics/AbcSize
protected protected
...@@ -261,9 +253,7 @@ module Backup ...@@ -261,9 +253,7 @@ module Backup
def prepare def prepare
FileUtils.rm_rf(backup_repos_path) FileUtils.rm_rf(backup_repos_path)
# Ensure the parent dir of backup_repos_path exists
FileUtils.mkdir_p(Gitlab.config.backup.path) FileUtils.mkdir_p(Gitlab.config.backup.path)
# Fail if somebody raced to create backup_repos_path before us
FileUtils.mkdir(backup_repos_path, mode: 0700) FileUtils.mkdir(backup_repos_path, mode: 0700)
end end
...@@ -279,7 +269,6 @@ module Backup ...@@ -279,7 +269,6 @@ module Backup
end end
def empty_repo?(project_or_wiki) def empty_repo?(project_or_wiki)
# Protect against stale caches
project_or_wiki.repository.expire_emptiness_caches project_or_wiki.repository.expire_emptiness_caches
project_or_wiki.repository.empty? project_or_wiki.repository.empty?
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment