Commit 5b302854 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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
parents caf1c9d8 bf3c0aaf
...@@ -150,17 +150,15 @@ module Backup ...@@ -150,17 +150,15 @@ module Backup
private private
def backup_contents 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 end
def folders_to_backup def archives_to_backup
folders = %w{repositories db} %w{uploads builds artifacts}.map{ |name| (name + ".tar.gz") unless skipped?(name) }.compact
if ENV["SKIP"]
return folders.reject{ |folder| ENV["SKIP"].include?(folder) }
end end
folders def folders_to_backup
%w{repositories db}.reject{ |name| skipped?(name) }
end end
def settings def settings
......
...@@ -149,7 +149,7 @@ describe 'gitlab:app namespace rake task' do ...@@ -149,7 +149,7 @@ describe 'gitlab:app namespace rake task' do
# Redirect STDOUT and run the rake task # Redirect STDOUT and run the rake task
orig_stdout = $stdout orig_stdout = $stdout
$stdout = StringIO.new $stdout = StringIO.new
ENV["SKIP"] = "repositories" ENV["SKIP"] = "repositories,uploads"
run_rake_task('gitlab:backup:create') run_rake_task('gitlab:backup:create')
$stdout = orig_stdout $stdout = orig_stdout
...@@ -180,6 +180,7 @@ describe 'gitlab:app namespace rake task' do ...@@ -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:db:restore"]).to receive :invoke
expect(Rake::Task["gitlab:backup:repo:restore"]).not_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:builds:restore"]).to receive :invoke
expect(Rake::Task["gitlab:backup:artifacts:restore"]).to receive :invoke expect(Rake::Task["gitlab:backup:artifacts:restore"]).to receive :invoke
expect(Rake::Task["gitlab:shell:setup"]).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