summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-19 10:00:58 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-19 10:00:58 +0000
commit5b30285407a050600c35145632d6901e81d94355 (patch)
tree79c72885cea50e329caf7368a69a5e7551a16f2e
parentcaf1c9d85bb9df05b8e7f90e1a844fe8ecb5a857 (diff)
parentbf3c0aafaa17c2e322d225180fd9708ec2827ac4 (diff)
downloadgitlab-ce-5b30285407a050600c35145632d6901e81d94355.tar.gz
Merge branch 'check_if_it_should_be_archived_in_backup' into 'master'
Check which folders and archives should be packed before passing to tar command. If user uses backup task with SKIP and skips one of the archives listed(uploads, builds, artifacts) backup create will give an error: `Cannot stat: No such file or directory`. This MR fixes that by checking for skipped items. Additionally, compact everything to avoid `TypeError: no implicit conversion of nil into String` errors. See merge request !1824
-rw-r--r--lib/backup/manager.rb14
-rw-r--r--spec/tasks/gitlab/backup_rake_spec.rb3
2 files changed, 8 insertions, 9 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index 9e15d5411a1..e7eda7c6f45 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -150,17 +150,15 @@ module Backup
private
def backup_contents
- folders_to_backup + ["uploads.tar.gz", "builds.tar.gz", "artifacts.tar.gz", "backup_information.yml"]
+ folders_to_backup + archives_to_backup + ["backup_information.yml"]
end
- def folders_to_backup
- folders = %w{repositories db}
-
- if ENV["SKIP"]
- return folders.reject{ |folder| ENV["SKIP"].include?(folder) }
- end
+ def archives_to_backup
+ %w{uploads builds artifacts}.map{ |name| (name + ".tar.gz") unless skipped?(name) }.compact
+ end
- folders
+ def folders_to_backup
+ %w{repositories db}.reject{ |name| skipped?(name) }
end
def settings
diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb
index 06559c3925d..fb5e74af648 100644
--- a/spec/tasks/gitlab/backup_rake_spec.rb
+++ b/spec/tasks/gitlab/backup_rake_spec.rb
@@ -149,7 +149,7 @@ describe 'gitlab:app namespace rake task' do
# Redirect STDOUT and run the rake task
orig_stdout = $stdout
$stdout = StringIO.new
- ENV["SKIP"] = "repositories"
+ ENV["SKIP"] = "repositories,uploads"
run_rake_task('gitlab:backup:create')
$stdout = orig_stdout
@@ -180,6 +180,7 @@ describe 'gitlab:app namespace rake task' do
expect(Rake::Task["gitlab:backup:db:restore"]).to receive :invoke
expect(Rake::Task["gitlab:backup:repo:restore"]).not_to receive :invoke
+ expect(Rake::Task["gitlab:backup:uploads:restore"]).not_to receive :invoke
expect(Rake::Task["gitlab:backup:builds:restore"]).to receive :invoke
expect(Rake::Task["gitlab:backup:artifacts:restore"]).to receive :invoke
expect(Rake::Task["gitlab:shell:setup"]).to receive :invoke