Commit c1cd9182 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch 'skr-tmp-delete' into 'master'

Delete backups/tmp after restore

See merge request gitlab-org/gitlab!67741
parents 7d464a8f 70c0e8b5
......@@ -72,6 +72,17 @@ module Backup
end
end
def remove_tmp
# delete tmp inside backups
progress.print "Deleting backups/tmp ... "
if FileUtils.rm_rf(File.join(backup_path, "tmp"))
progress.puts "done".color(:green)
else
puts "deleting backups/tmp failed".color(:red)
end
end
def remove_old
# delete backups
progress.print "Deleting old backups ... "
......
......@@ -91,6 +91,8 @@ namespace :gitlab do
backup.cleanup
end
backup.remove_tmp
puts "Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data \n" \
"and are not included in this backup. You will need to restore these files manually.".color(:red)
puts "Restore task is done."
......
......@@ -88,6 +88,27 @@ RSpec.describe Backup::Manager do
end
end
describe '#remove_tmp' do
let(:path) { File.join(Gitlab.config.backup.path, 'tmp') }
before do
allow(FileUtils).to receive(:rm_rf).and_return(true)
end
it 'removes backups/tmp dir' do
subject.remove_tmp
expect(FileUtils).to have_received(:rm_rf).with(path)
end
it 'prints running task with a done confirmation' do
subject.remove_tmp
expect(progress).to have_received(:print).with('Deleting backups/tmp ... ')
expect(progress).to have_received(:puts).with('done')
end
end
describe '#remove_old' do
let(:files) do
[
......
......@@ -490,8 +490,7 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do
'lfs.tar.gz',
'pages.tar.gz',
'registry.tar.gz',
'repositories',
'tmp'
'repositories'
)
end
......
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