BigW Consortium Gitlab

Commit 9c82bca5 by Angus MacArthur

fixes for gitlab restore with non-standard backup and repo dirs

These fixes will allow a restore of gitlab when the backups and repositories directories are in non-standard locations (ie sub-dirs of gitlabhq). Also allows the restore to be run from script overriding the need of a user to confirm the rebuild of the authorized_keys file.
parent 63937577
......@@ -71,7 +71,7 @@ module Backup
print 'Put GitLab hooks in repositories dirs'.yellow
gitlab_shell_user_home = File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
if system("#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh")
if system("#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh #{Gitlab.config.gitlab_shell.repos_path}")
puts " [DONE]".green
else
puts " [FAILED]".red
......
......@@ -90,6 +90,9 @@ namespace :gitlab do
settings = YAML.load_file("backup_information.yml")
ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0
# backups directory is not always sub of Rails root and able to execute the git rev-parse below
Dir.chdir(Rails.root)
# restoring mismatching backups can lead to unexpected problems
if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/,"")
puts "GitLab version mismatch:".red
......
......@@ -26,10 +26,12 @@ namespace :gitlab do
warn_user_is_not_gitlab
gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys')
puts "This will rebuild an authorized_keys file."
puts "You will lose any data stored in #{gitlab_shell_authorized_keys}."
ask_to_continue
puts ""
unless ENV['force'] == 'yes'
puts "This will rebuild an authorized_keys file."
puts "You will lose any data stored in #{gitlab_shell_authorized_keys}."
ask_to_continue
puts ""
end
system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}")
......
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