Commit db9a6013311229e546d7ba53adc61e2bf44f7570
1 parent
58968522
Exists in
6-6-stable-ee
and in
1 other branch
Backport gitlab-rails backup script improvement
Showing
3 changed files
with
48 additions
and
24 deletions
Show diff stats
config/patches/gitlab-rails/backup_read_REVISION.patch
| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | -diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb | |
| 2 | -index efaefa4..8f0e38f 100644 | |
| 3 | ---- a/lib/backup/manager.rb | |
| 4 | -+++ b/lib/backup/manager.rb | |
| 5 | -@@ -7,7 +7,7 @@ module Backup | |
| 6 | - s = {} | |
| 7 | - s[:db_version] = "#{ActiveRecord::Migrator.current_version}" | |
| 8 | - s[:backup_created_at] = Time.now | |
| 9 | -- s[:gitlab_version] = %x{git rev-parse HEAD}.gsub(/\n/,"") | |
| 10 | -+ s[:gitlab_version] = File.read(Rails.root.join('REVISION')).chomp | |
| 11 | - s[:tar_version] = %x{tar --version | head -1}.gsub(/\n/,"") | |
| 12 | - | |
| 13 | - Dir.chdir(Gitlab.config.backup.path) | |
| 14 | -@@ -92,7 +92,7 @@ module Backup | |
| 15 | - Dir.chdir(Rails.root) | |
| 16 | - | |
| 17 | - # restoring mismatching backups can lead to unexpected problems | |
| 18 | -- if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/, "") | |
| 19 | -+ if settings[:gitlab_version] != File.read(Rails.root.join('REVISION')).chomp | |
| 20 | - puts "GitLab version mismatch:".red | |
| 21 | - puts " Your current HEAD differs from the HEAD in the backup!".red | |
| 22 | - puts " Please switch to the following revision and try again:".red |
| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | +diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb | |
| 2 | +index efaefa4..a93d35a 100644 | |
| 3 | +--- a/lib/backup/manager.rb | |
| 4 | ++++ b/lib/backup/manager.rb | |
| 5 | +@@ -7,7 +7,7 @@ module Backup | |
| 6 | + s = {} | |
| 7 | + s[:db_version] = "#{ActiveRecord::Migrator.current_version}" | |
| 8 | + s[:backup_created_at] = Time.now | |
| 9 | +- s[:gitlab_version] = %x{git rev-parse HEAD}.gsub(/\n/,"") | |
| 10 | ++ s[:gitlab_version] = Gitlab::VERSION | |
| 11 | + s[:tar_version] = %x{tar --version | head -1}.gsub(/\n/,"") | |
| 12 | + | |
| 13 | + Dir.chdir(Gitlab.config.backup.path) | |
| 14 | +@@ -87,21 +87,15 @@ module Backup | |
| 15 | + settings = YAML.load_file("backup_information.yml") | |
| 16 | + ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0 | |
| 17 | + | |
| 18 | +- # backups directory is not always sub of Rails root and able to execute the git rev-parse below | |
| 19 | +- begin | |
| 20 | +- Dir.chdir(Rails.root) | |
| 21 | +- | |
| 22 | +- # restoring mismatching backups can lead to unexpected problems | |
| 23 | +- if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/, "") | |
| 24 | +- puts "GitLab version mismatch:".red | |
| 25 | +- puts " Your current HEAD differs from the HEAD in the backup!".red | |
| 26 | +- puts " Please switch to the following revision and try again:".red | |
| 27 | +- puts " revision: #{settings[:gitlab_version]}".red | |
| 28 | +- exit 1 | |
| 29 | +- end | |
| 30 | +- ensure | |
| 31 | +- # chdir back to original intended dir | |
| 32 | +- Dir.chdir(Gitlab.config.backup.path) | |
| 33 | ++ # restoring mismatching backups can lead to unexpected problems | |
| 34 | ++ if settings[:gitlab_version] != Gitlab::VERSION | |
| 35 | ++ puts "GitLab version mismatch:".red | |
| 36 | ++ puts " Your current GitLab version (#{Gitlab::VERSION}) differs from the GitLab version in the backup!".red | |
| 37 | ++ puts " Please switch to the following version and try again:".red | |
| 38 | ++ puts " version: #{settings[:gitlab_version]}".red | |
| 39 | ++ puts | |
| 40 | ++ puts "Hint: git checkout v#{settings[:gitlab_version]}" | |
| 41 | ++ exit 1 | |
| 42 | + end | |
| 43 | + end | |
| 44 | + end | ... | ... |
config/software/gitlab-rails.rb
| ... | ... | @@ -43,8 +43,10 @@ build do |
| 43 | 43 | # source code to include the Git revision of the code included in the omnibus |
| 44 | 44 | # build. |
| 45 | 45 | command "sed -i \"s/.*REVISION.*/REVISION = '$(git log --pretty=format:'%h' -n 1)'/\" config/initializers/2_app.rb" |
| 46 | - patch :source => "backup_read_REVISION.patch" | |
| 47 | - command "git rev-parse HEAD > REVISION" | |
| 46 | + | |
| 47 | + # gitlab-rails master has improved the versioning logic for backups. The old | |
| 48 | + # solution is painful for omnibus-gitlab so we are backporting the improvement. | |
| 49 | + patch :source => "backup_use_VERSION.patch" | |
| 48 | 50 | |
| 49 | 51 | # The user uploads path is not (yet) configurable in gitlab-rails. As a |
| 50 | 52 | # workaround, omnibus-gitlab creates a symlink for public/uploads. This breaks | ... | ... |