summaryrefslogtreecommitdiff
path: root/lib/backup
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-02-27 14:30:41 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-02-27 14:30:41 +0100
commit75f274b7505935cc5fd0b609a83afb1c8aaba79b (patch)
tree5d230555582102a474e89235877af0a9ef50ec4e /lib/backup
parent0a963ee15a3c544fcf647ae94d348fe3369251c9 (diff)
downloadgitlab-ce-75f274b7505935cc5fd0b609a83afb1c8aaba79b.tar.gz
Use Gitlab::VERSION to version backups
Previous to this commit, backups were tied to the git revision (SHA1) of the app at the time the backup:create command was invoked. If the SHA1 at the time of restore was different, the script would refuse to restore the backup. This commit loosens this tie so that the backup script only complains if the value of the Gitlab::VERSION constant is different between the time of backup and the time of restore.
Diffstat (limited to 'lib/backup')
-rw-r--r--lib/backup/manager.rb26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index efaefa4ce44..a93d35a1cd1 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -7,7 +7,7 @@ module Backup
s = {}
s[:db_version] = "#{ActiveRecord::Migrator.current_version}"
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/,"")
Dir.chdir(Gitlab.config.backup.path)
@@ -87,21 +87,15 @@ module Backup
settings = YAML.load_file("backup_information.yml")
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
- if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/, "")
- puts "GitLab version mismatch:".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 " revision: #{settings[:gitlab_version]}".red
- exit 1
- end
- ensure
- # chdir back to original intended dir
- Dir.chdir(Gitlab.config.backup.path)
+ # restoring mismatching backups can lead to unexpected problems
+ if settings[:gitlab_version] != Gitlab::VERSION
+ puts "GitLab version mismatch:".red
+ puts " Your current GitLab version (#{Gitlab::VERSION}) differs from the GitLab version in the backup!".red
+ puts " Please switch to the following version and try again:".red
+ puts " version: #{settings[:gitlab_version]}".red
+ puts
+ puts "Hint: git checkout v#{settings[:gitlab_version]}"
+ exit 1
end
end
end