Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
70c0e8b5
Commit
70c0e8b5
authored
Aug 09, 2021
by
Shubham Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete backups/tmp after restore
Changelog: fixed
parent
e9cfc62c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
2 deletions
+35
-2
lib/backup/manager.rb
lib/backup/manager.rb
+11
-0
lib/tasks/gitlab/backup.rake
lib/tasks/gitlab/backup.rake
+2
-0
spec/lib/backup/manager_spec.rb
spec/lib/backup/manager_spec.rb
+21
-0
spec/tasks/gitlab/backup_rake_spec.rb
spec/tasks/gitlab/backup_rake_spec.rb
+1
-2
No files found.
lib/backup/manager.rb
View file @
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 ... "
...
...
lib/tasks/gitlab/backup.rake
View file @
70c0e8b5
...
...
@@ -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."
...
...
spec/lib/backup/manager_spec.rb
View file @
70c0e8b5
...
...
@@ -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
[
...
...
spec/tasks/gitlab/backup_rake_spec.rb
View file @
70c0e8b5
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment