diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-05-25 09:28:22 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-05-25 09:28:22 +0000 |
commit | 019a3c781efd75a8ce44297519a724e322cfde96 (patch) | |
tree | d1621bead9bddc963f05bb42c61fe51728c5525b /lib | |
parent | 4618e538be02eaa324b21de4b1d7a34f1359e025 (diff) | |
parent | 718fe268c48b3b77b2b3d901b0c688a06e82053d (diff) | |
download | gitlab-ce-019a3c781efd75a8ce44297519a724e322cfde96.tar.gz |
Merge branch 'fix-registry-backups' into 'master'
Fix backups if registry is disabled
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/17749
See merge request !4263
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backup/manager.rb | 15 | ||||
-rw-r--r-- | lib/tasks/gitlab/backup.rake | 20 |
2 files changed, 26 insertions, 9 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index 7d0608f09da..3e07096e6cc 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -1,5 +1,8 @@ module Backup class Manager + ARCHIVES_TO_BACKUP = %w[uploads builds artifacts lfs registry] + FOLDERS_TO_BACKUP = %w[repositories db] + def pack # Make sure there is a connection ActiveRecord::Base.connection.reconnect! @@ -147,7 +150,7 @@ module Backup end def skipped?(item) - settings[:skipped] && settings[:skipped].include?(item) + settings[:skipped] && settings[:skipped].include?(item) || disabled_features.include?(item) end private @@ -157,11 +160,17 @@ module Backup end def archives_to_backup - %w{uploads builds artifacts lfs registry}.map{ |name| (name + ".tar.gz") unless skipped?(name) }.compact + ARCHIVES_TO_BACKUP.map{ |name| (name + ".tar.gz") unless skipped?(name) }.compact end def folders_to_backup - %w{repositories db}.reject{ |name| skipped?(name) } + FOLDERS_TO_BACKUP.reject{ |name| skipped?(name) } + end + + def disabled_features + features = [] + features << 'registry' unless Gitlab.config.registry.enabled + features end def settings diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index d97d974ec20..596eaca6d0d 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -179,18 +179,26 @@ namespace :gitlab do task create: :environment do $progress.puts "Dumping container registry images ... ".blue - if ENV["SKIP"] && ENV["SKIP"].include?("registry") - $progress.puts "[SKIPPED]".cyan + if Gitlab.config.registry.enabled + if ENV["SKIP"] && ENV["SKIP"].include?("registry") + $progress.puts "[SKIPPED]".cyan + else + Backup::Registry.new.dump + $progress.puts "done".green + end else - Backup::Registry.new.dump - $progress.puts "done".green + $progress.puts "[DISABLED]".cyan end end task restore: :environment do $progress.puts "Restoring container registry images ... ".blue - Backup::Registry.new.restore - $progress.puts "done".green + if Gitlab.config.registry.enabled + Backup::Registry.new.restore + $progress.puts "done".green + else + $progress.puts "[DISABLED]".cyan + end end end |