diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-07-30 10:17:34 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-07-30 10:17:34 +0200 |
commit | baa157926d432f404a41c31ad6514ff8d5366269 (patch) | |
tree | 106b84811dfd7a832fd82300f590dd3763621bc4 /lib/backup/database.rb | |
parent | c5aae3077335ab0eaafb73f51548d4c85413a1d1 (diff) | |
download | gitlab-ce-baa157926d432f404a41c31ad6514ff8d5366269.tar.gz |
Stricter mkdir's in 'rake gitlab:backup:create'backup-directory-permissions
Diffstat (limited to 'lib/backup/database.rb')
-rw-r--r-- | lib/backup/database.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/backup/database.rb b/lib/backup/database.rb index 8450019980f..bbb230a10f0 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -7,7 +7,11 @@ module Backup def initialize @config = YAML.load_file(File.join(Rails.root,'config','database.yml'))[Rails.env] @db_dir = File.join(Gitlab.config.backup.path, 'db') - FileUtils.mkdir_p(@db_dir, mode: 0700)unless Dir.exists?(@db_dir) + FileUtils.rm_rf(@db_dir) + # Ensure the parent dir of @db_dir exists + FileUtils.mkdir_p(Gitlab.config.backup.path) + # Fail if somebody raced to create @db_dir before us + FileUtils.mkdir(@db_dir, mode: 0700) end def dump @@ -25,7 +29,6 @@ module Backup abort 'Backup failed' unless success $progress.print 'Compressing database ... ' - FileUtils.rm_f db_file_name_gz success = system('gzip', db_file_name) report_success(success) abort 'Backup failed: compress error' unless success |