Merge pull request #4140 from amacarthur/restore-fixes-clean
fixes for gitlab restore with non-standard backup and repo dirs
This commit is contained in:
commit
5cd988249f
|
@ -71,7 +71,7 @@ module Backup
|
||||||
|
|
||||||
print 'Put GitLab hooks in repositories dirs'.yellow
|
print 'Put GitLab hooks in repositories dirs'.yellow
|
||||||
gitlab_shell_user_home = File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
|
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
|
puts " [DONE]".green
|
||||||
else
|
else
|
||||||
puts " [FAILED]".red
|
puts " [FAILED]".red
|
||||||
|
|
|
@ -90,14 +90,22 @@ namespace :gitlab do
|
||||||
settings = YAML.load_file("backup_information.yml")
|
settings = YAML.load_file("backup_information.yml")
|
||||||
ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0
|
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
|
||||||
|
begin
|
||||||
|
Dir.chdir(Rails.root)
|
||||||
|
|
||||||
# restoring mismatching backups can lead to unexpected problems
|
# restoring mismatching backups can lead to unexpected problems
|
||||||
if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/,"")
|
if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/, "")
|
||||||
puts "GitLab version mismatch:".red
|
puts "GitLab version mismatch:".red
|
||||||
puts " Your current HEAD differs from the HEAD in the backup!".red
|
puts " Your current HEAD differs from the HEAD in the backup!".red
|
||||||
puts " Please switch to the following revision and try again:".red
|
puts " Please switch to the following revision and try again:".red
|
||||||
puts " revision: #{settings[:gitlab_version]}".red
|
puts " revision: #{settings[:gitlab_version]}".red
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
# chdir back to original intended dir
|
||||||
|
Dir.chdir(Gitlab.config.backup.path)
|
||||||
|
end
|
||||||
|
|
||||||
Rake::Task["gitlab:backup:db:restore"].invoke
|
Rake::Task["gitlab:backup:db:restore"].invoke
|
||||||
Rake::Task["gitlab:backup:repo:restore"].invoke
|
Rake::Task["gitlab:backup:repo:restore"].invoke
|
||||||
|
|
|
@ -26,10 +26,12 @@ namespace :gitlab do
|
||||||
warn_user_is_not_gitlab
|
warn_user_is_not_gitlab
|
||||||
|
|
||||||
gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys')
|
gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys')
|
||||||
|
unless ENV['force'] == 'yes'
|
||||||
puts "This will rebuild an authorized_keys file."
|
puts "This will rebuild an authorized_keys file."
|
||||||
puts "You will lose any data stored in #{gitlab_shell_authorized_keys}."
|
puts "You will lose any data stored in #{gitlab_shell_authorized_keys}."
|
||||||
ask_to_continue
|
ask_to_continue
|
||||||
puts ""
|
puts ""
|
||||||
|
end
|
||||||
|
|
||||||
system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}")
|
system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue