Commit 9c82bca5ee274d700ec3166d4521d4c6d2ff896c
1 parent
63937577
Exists in
master
and in
4 other branches
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.
Showing
3 changed files
with
10 additions
and
5 deletions
Show diff stats
lib/backup/repository.rb
| ... | ... | @@ -71,7 +71,7 @@ module Backup |
| 71 | 71 | |
| 72 | 72 | print 'Put GitLab hooks in repositories dirs'.yellow |
| 73 | 73 | gitlab_shell_user_home = File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") |
| 74 | - if system("#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh") | |
| 74 | + if system("#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh #{Gitlab.config.gitlab_shell.repos_path}") | |
| 75 | 75 | puts " [DONE]".green |
| 76 | 76 | else |
| 77 | 77 | puts " [FAILED]".red | ... | ... |
lib/tasks/gitlab/backup.rake
| ... | ... | @@ -90,6 +90,9 @@ namespace :gitlab do |
| 90 | 90 | settings = YAML.load_file("backup_information.yml") |
| 91 | 91 | ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0 |
| 92 | 92 | |
| 93 | + # backups directory is not always sub of Rails root and able to execute the git rev-parse below | |
| 94 | + Dir.chdir(Rails.root) | |
| 95 | + | |
| 93 | 96 | # restoring mismatching backups can lead to unexpected problems |
| 94 | 97 | if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/,"") |
| 95 | 98 | puts "GitLab version mismatch:".red | ... | ... |
lib/tasks/gitlab/shell.rake
| ... | ... | @@ -26,10 +26,12 @@ namespace :gitlab do |
| 26 | 26 | warn_user_is_not_gitlab |
| 27 | 27 | |
| 28 | 28 | gitlab_shell_authorized_keys = File.join(File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}"),'.ssh/authorized_keys') |
| 29 | - puts "This will rebuild an authorized_keys file." | |
| 30 | - puts "You will lose any data stored in #{gitlab_shell_authorized_keys}." | |
| 31 | - ask_to_continue | |
| 32 | - puts "" | |
| 29 | + unless ENV['force'] == 'yes' | |
| 30 | + puts "This will rebuild an authorized_keys file." | |
| 31 | + puts "You will lose any data stored in #{gitlab_shell_authorized_keys}." | |
| 32 | + ask_to_continue | |
| 33 | + puts "" | |
| 34 | + end | |
| 33 | 35 | |
| 34 | 36 | system("echo '# Managed by gitlab-shell' > #{gitlab_shell_authorized_keys}") |
| 35 | 37 | ... | ... |