Modified the repo_dump
and repo_restore
rake tasks to properly dump and restore repositories based on their path
rather than their (project) name
. The project name can be uppercase and may contain spaces. This caused the repository to be restored as a different path
that it was initially created as, thus, breaking the git remote
and the web interface can no longer detect the repository either because it searches by path
and not by name
. Also, when restoring the permissions are incorrect making it impossible to push new commits to the remote repository. So now on success it'll set the correct permissions (but requires that the gitlab
user has sudo
privileges, or this task must be executed as root).
This commit is contained in:
parent
8b7e404b5b
commit
ec01cbef94
1 changed files with 4 additions and 2 deletions
|
@ -121,7 +121,7 @@ namespace :gitlab do
|
|||
backup_path_repo = File.join(Gitlab.config.backup_path, "repositories")
|
||||
FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo)
|
||||
puts "Dumping repositories:"
|
||||
project = Project.all.map { |n| [n.name,n.path_to_repo] }
|
||||
project = Project.all.map { |n| [n.path,n.path_to_repo] }
|
||||
project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")]
|
||||
project.each do |project|
|
||||
print "- Dumping repository #{project.first}... "
|
||||
|
@ -136,12 +136,14 @@ namespace :gitlab do
|
|||
task :repo_restore => :environment do
|
||||
backup_path_repo = File.join(Gitlab.config.backup_path, "repositories")
|
||||
puts "Restoring repositories:"
|
||||
project = Project.all.map { |n| [n.name,n.path_to_repo] }
|
||||
project = Project.all.map { |n| [n.path,n.path_to_repo] }
|
||||
project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")]
|
||||
project.each do |project|
|
||||
print "- Restoring repository #{project.first}... "
|
||||
FileUtils.rm_rf(project.second) if File.dirname(project.second) # delet old stuff
|
||||
if Kernel.system("cd #{File.dirname(project.second)} > /dev/null 2>&1 && git clone --bare #{backup_path_repo}/#{project.first}.bundle #{project.first}.git > /dev/null 2>&1")
|
||||
Kernel.system("sudo chmod -R g+rwX #{Gitlab.config.git_base_path}")
|
||||
Kernel.system("sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}")
|
||||
puts "[DONE]".green
|
||||
else
|
||||
puts "[FAILED]".red
|
||||
|
|
Loading…
Reference in a new issue