diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-03-26 15:47:52 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-03-26 15:47:52 +0000 |
commit | fe2e1ac3210d85e10c56cf226e7fffee738ac780 (patch) | |
tree | cab372348af165df2fbd65b8c0d61ee722c545f8 | |
parent | 3b1b6ec135333966f9dafc7b7b14087514f82b56 (diff) | |
parent | 083027fc84e61f5b592ed43cdbdb8425e17d2a7f (diff) | |
download | gitlab-ce-fe2e1ac3210d85e10c56cf226e7fffee738ac780.tar.gz |
Merge branch 'backup-chdir' into 'master'
Change directory when removing old backups
Fixes errors when deleting old backups in the `gitlab:backup:create` rake task. See #2177.
See merge request !1740
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/backup/manager.rb | 15 |
2 files changed, 9 insertions, 7 deletions
diff --git a/CHANGELOG b/CHANGELOG index d16f20266cb..3c3ebd894b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,7 @@ v 7.10.0 (unreleased) - Passing the name of pushed ref to CI service (requires GitLab CI 7.9+) - Add location field to user profile - Fix print view for markdown files and wiki pages + - Fix errors when deleting old backups - Improve GitLab performance when working with git repositories - Add tag message and last commit to tag hook (Kamil TrzciĆski) - Restrict permissions on backup files 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 |