Commit 61c6e969 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets Committed by Robert Speicher

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
parent 32771f06
......@@ -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
......
......@@ -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
......
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