summaryrefslogtreecommitdiff
path: root/lib/backup/repository.rb
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2016-06-22 17:04:51 -0400
committerAlejandro Rodríguez <alejorro70@gmail.com>2016-06-29 22:30:31 -0400
commit86359ec854314574dccea75247f45590262b05c0 (patch)
tree52aaf922e5a6fc63b0d42095322f79cdae659b43 /lib/backup/repository.rb
parentb32a6add8fa602eb35648f3f4661df8b98d909cb (diff)
downloadgitlab-ce-86359ec854314574dccea75247f45590262b05c0.tar.gz
Refactor repository paths handling to allow multiple git mount points
Diffstat (limited to 'lib/backup/repository.rb')
-rw-r--r--lib/backup/repository.rb26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb
index 7b91215d50b..b9773f98d75 100644
--- a/lib/backup/repository.rb
+++ b/lib/backup/repository.rb
@@ -2,8 +2,6 @@ require 'yaml'
module Backup
class Repository
- attr_reader :repos_path
-
def dump
prepare
@@ -50,10 +48,12 @@ module Backup
end
def restore
- if File.exists?(repos_path)
+ Gitlab.config.repositories.storages.each do |name, path|
+ next unless File.exists?(path)
+
# Move repos dir to 'repositories.old' dir
- bk_repos_path = File.join(repos_path, '..', 'repositories.old.' + Time.now.to_i.to_s)
- FileUtils.mv(repos_path, bk_repos_path)
+ bk_repos_path = File.join(path, '..', 'repositories.old.' + Time.now.to_i.to_s)
+ FileUtils.mv(path, bk_repos_path)
end
FileUtils.mkdir_p(repos_path)
@@ -61,7 +61,7 @@ module Backup
Project.find_each(batch_size: 1000) do |project|
$progress.print " * #{project.path_with_namespace} ... "
- project.namespace.ensure_dir_exist if project.namespace
+ project.ensure_dir_exist
if File.exists?(path_to_bundle(project))
FileUtils.mkdir_p(path_to_repo(project))
@@ -100,8 +100,8 @@ module Backup
end
$progress.print 'Put GitLab hooks in repositories dirs'.color(:yellow)
- cmd = "#{Gitlab.config.gitlab_shell.path}/bin/create-hooks"
- if system(cmd)
+ cmd = %W(#{Gitlab.config.gitlab_shell.path}/bin/create-hooks) + repository_storage_paths_args
+ if system(*cmd)
$progress.puts " [DONE]".color(:green)
else
puts " [FAILED]".color(:red)
@@ -120,10 +120,6 @@ module Backup
File.join(backup_repos_path, project.path_with_namespace + ".bundle")
end
- def repos_path
- Gitlab.config.gitlab_shell.repos_path
- end
-
def backup_repos_path
File.join(Gitlab.config.backup.path, "repositories")
end
@@ -139,5 +135,11 @@ module Backup
def silent
{err: '/dev/null', out: '/dev/null'}
end
+
+ private
+
+ def repository_storage_paths_args
+ Gitlab.config.repositories.storages.values
+ end
end
end