Commit 5f4fea17ad42d24f069d19d36853b7ea61ee66c8
1 parent
9c82bca5
Exists in
master
and in
4 other branches
Correction to restore expected current directory
Showing
1 changed file
with
14 additions
and
9 deletions
Show diff stats
lib/tasks/gitlab/backup.rake
| @@ -91,15 +91,20 @@ namespace :gitlab do | @@ -91,15 +91,20 @@ namespace :gitlab do | ||
| 91 | ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0 | 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 | 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 | - | ||
| 96 | - # restoring mismatching backups can lead to unexpected problems | ||
| 97 | - if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/,"") | ||
| 98 | - puts "GitLab version mismatch:".red | ||
| 99 | - puts " Your current HEAD differs from the HEAD in the backup!".red | ||
| 100 | - puts " Please switch to the following revision and try again:".red | ||
| 101 | - puts " revision: #{settings[:gitlab_version]}".red | ||
| 102 | - exit 1 | 94 | + begin |
| 95 | + Dir.chdir(Rails.root) | ||
| 96 | + | ||
| 97 | + # restoring mismatching backups can lead to unexpected problems | ||
| 98 | + if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/, "") | ||
| 99 | + puts "GitLab version mismatch:".red | ||
| 100 | + puts " Your current HEAD differs from the HEAD in the backup!".red | ||
| 101 | + puts " Please switch to the following revision and try again:".red | ||
| 102 | + puts " revision: #{settings[:gitlab_version]}".red | ||
| 103 | + exit 1 | ||
| 104 | + end | ||
| 105 | + ensure | ||
| 106 | + # chdir back to original intended dir | ||
| 107 | + Dir.chdir(Gitlab.config.backup.path) | ||
| 103 | end | 108 | end |
| 104 | 109 | ||
| 105 | Rake::Task["gitlab:backup:db:restore"].invoke | 110 | Rake::Task["gitlab:backup:db:restore"].invoke |