Commit 1f9b3f2e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'backup_version' into 'master'

Less strict backup versions
parents 0a963ee1 75f274b7
...@@ -7,7 +7,7 @@ module Backup ...@@ -7,7 +7,7 @@ module Backup
s = {} s = {}
s[:db_version] = "#{ActiveRecord::Migrator.current_version}" s[:db_version] = "#{ActiveRecord::Migrator.current_version}"
s[:backup_created_at] = Time.now s[:backup_created_at] = Time.now
s[:gitlab_version] = %x{git rev-parse HEAD}.gsub(/\n/,"") s[:gitlab_version] = Gitlab::VERSION
s[:tar_version] = %x{tar --version | head -1}.gsub(/\n/,"") s[:tar_version] = %x{tar --version | head -1}.gsub(/\n/,"")
Dir.chdir(Gitlab.config.backup.path) Dir.chdir(Gitlab.config.backup.path)
...@@ -87,22 +87,16 @@ module Backup ...@@ -87,22 +87,16 @@ module Backup
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] != Gitlab::VERSION
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 GitLab version (#{Gitlab::VERSION}) differs from the GitLab version in the backup!".red
puts " Please switch to the following revision and try again:".red puts " Please switch to the following version and try again:".red
puts " revision: #{settings[:gitlab_version]}".red puts " version: #{settings[:gitlab_version]}".red
puts
puts "Hint: git checkout v#{settings[:gitlab_version]}"
exit 1 exit 1
end end
ensure
# chdir back to original intended dir
Dir.chdir(Gitlab.config.backup.path)
end
end end
end end
end end
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