summaryrefslogtreecommitdiff
path: root/lib/backup
diff options
context:
space:
mode:
authorVinnie Okada <vokada@mrvinn.com>2015-03-24 20:37:19 -0600
committerVinnie Okada <vokada@mrvinn.com>2015-03-24 20:47:11 -0600
commit083027fc84e61f5b592ed43cdbdb8425e17d2a7f (patch)
treef28559e456bd186df2575c205542b51bac6a4432 /lib/backup
parentb9372c999707558b695fa401b4f660a3d38fce86 (diff)
downloadgitlab-ce-083027fc84e61f5b592ed43cdbdb8425e17d2a7f.tar.gz
Change directory when removing old backups
Diffstat (limited to 'lib/backup')
-rw-r--r--lib/backup/manager.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index c6087830b40..afd05897509 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -70,16 +70,17 @@ module Backup
# delete backups
$progress.print "Deleting old backups ... "
keep_time = Gitlab.config.backup.keep_time.to_i
- path = Gitlab.config.backup.path
if keep_time > 0
removed = 0
- file_list = Dir.glob(Rails.root.join(path, "*_gitlab_backup.tar"))
- file_list.map! { |f| $1.to_i if f =~ /(\d+)_gitlab_backup.tar/ }
- file_list.sort.each do |timestamp|
- if Time.at(timestamp) < (Time.now - keep_time)
- if Kernel.system(*%W(rm #{timestamp}_gitlab_backup.tar))
- removed += 1
+ Dir.chdir(Gitlab.config.backup.path) do
+ file_list = Dir.glob('*_gitlab_backup.tar')
+ file_list.map! { |f| $1.to_i if f =~ /(\d+)_gitlab_backup.tar/ }
+ file_list.sort.each do |timestamp|
+ if Time.at(timestamp) < (Time.now - keep_time)
+ if Kernel.system(*%W(rm #{timestamp}_gitlab_backup.tar))
+ removed += 1
+ end
end
end
end