summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Hassan <ahmad.hassan612@gmail.com>2018-04-27 12:06:42 +0300
committerAhmad Hassan <ahmad.hassan612@gmail.com>2018-04-28 20:07:06 +0300
commit00d5be108bc93debcf466b37a6407fbe054aa902 (patch)
treef3a0c0b901ba003748843a968a33f42f1bb794e6
parent740f0bb126a4e7da94d9d0181d2023b14113c93e (diff)
downloadgitlab-ce-test-backup-restore.tar.gz
Gitaly restoretest-backup-restore
-rw-r--r--lib/backup/repository.rb103
1 files changed, 53 insertions, 50 deletions
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb
index 65e06fd78c0..1399d8ae237 100644
--- a/lib/backup/repository.rb
+++ b/lib/backup/repository.rb
@@ -11,59 +11,62 @@ module Backup
Project.find_each(batch_size: 1000) do |project|
progress.print " * #{display_repo_path(project)} ... "
- path_to_project_repo = path_to_repo(project)
+ # path_to_project_repo = path_to_repo(project)
path_to_project_bundle = path_to_bundle(project)
- # Create namespace dir or hashed path if missing
- if project.hashed_storage?(:repository)
- FileUtils.mkdir_p(File.dirname(File.join(backup_repos_path, project.disk_path)))
- else
- FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.full_path)) if project.namespace
- end
-
- if empty_repo?(project)
- progress.puts "[SKIPPED]".color(:cyan)
- else
- in_path(path_to_project_repo) do |dir|
- FileUtils.mkdir_p(path_to_tars(project))
- cmd = %W(tar -cf #{path_to_tars(project, dir)} -C #{path_to_project_repo} #{dir})
- output, status = Gitlab::Popen.popen(cmd)
-
- unless status.zero?
- progress_warn(project, cmd.join(' '), output)
- end
- end
-
- cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_project_repo} bundle create #{path_to_project_bundle} --all)
- output, status = Gitlab::Popen.popen(cmd)
-
- if status.zero?
- progress.puts "[DONE]".color(:green)
- else
- progress_warn(project, cmd.join(' '), output)
- end
- end
-
- wiki = ProjectWiki.new(project)
- path_to_wiki_repo = path_to_repo(wiki)
- path_to_wiki_bundle = path_to_bundle(wiki)
-
- if File.exist?(path_to_wiki_repo)
- progress.print " * #{display_repo_path(wiki)} ... "
-
- if empty_repo?(wiki)
- progress.puts " [SKIPPED]".color(:cyan)
- else
- cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_wiki_repo} bundle create #{path_to_wiki_bundle} --all)
- output, status = Gitlab::Popen.popen(cmd)
- if status.zero?
- progress.puts " [DONE]".color(:green)
- else
- progress_warn(wiki, cmd.join(' '), output)
- end
- end
+ if project.repository_exists?
+ project.repository.create_from_bundle(path_to_project_bundle)
end
- end
+ # # Create namespace dir or hashed path if missing
+ # if project.hashed_storage?(:repository)
+ # FileUtils.mkdir_p(File.dirname(File.join(backup_repos_path, project.disk_path)))
+ # else
+ # FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.full_path)) if project.namespace
+ # end
+ #
+ # if empty_repo?(project)
+ # progress.puts "[SKIPPED]".color(:cyan)
+ # else
+ # in_path(path_to_project_repo) do |dir|
+ # FileUtils.mkdir_p(path_to_tars(project))
+ # cmd = %W(tar -cf #{path_to_tars(project, dir)} -C #{path_to_project_repo} #{dir})
+ # output, status = Gitlab::Popen.popen(cmd)
+ #
+ # unless status.zero?
+ # progress_warn(project, cmd.join(' '), output)
+ # end
+ # end
+ #
+ # cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_project_repo} bundle create #{path_to_project_bundle} --all)
+ # output, status = Gitlab::Popen.popen(cmd)
+ #
+ # if status.zero?
+ # progress.puts "[DONE]".color(:green)
+ # else
+ # progress_warn(project, cmd.join(' '), output)
+ # end
+ # end
+ #
+ # wiki = ProjectWiki.new(project)
+ # path_to_wiki_repo = path_to_repo(wiki)
+ # path_to_wiki_bundle = path_to_bundle(wiki)
+ #
+ # if File.exist?(path_to_wiki_repo)
+ # progress.print " * #{display_repo_path(wiki)} ... "
+ #
+ # if empty_repo?(wiki)
+ # progress.puts " [SKIPPED]".color(:cyan)
+ # else
+ # cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_wiki_repo} bundle create #{path_to_wiki_bundle} --all)
+ # output, status = Gitlab::Popen.popen(cmd)
+ # if status.zero?
+ # progress.puts " [DONE]".color(:green)
+ # else
+ # progress_warn(wiki, cmd.join(' '), output)
+ # end
+ # end
+ # end
+ end
end
def prepare_directories