diff options
author | Vinnie Okada <vokada@mrvinn.com> | 2015-03-19 19:24:57 -0600 |
---|---|---|
committer | Vinnie Okada <vokada@mrvinn.com> | 2015-03-19 20:30:19 -0600 |
commit | 06aafb73640da21a4277961c5c6da61496f0e8db (patch) | |
tree | d0d5d37cea357f2d527a0ffcdf3620433aabfa20 /lib/backup | |
parent | abbea9a0daa009fff4efcee0743307ae27e49d65 (diff) | |
download | gitlab-ce-06aafb73640da21a4277961c5c6da61496f0e8db.tar.gz |
Call chdir() with a block
Diffstat (limited to 'lib/backup')
-rw-r--r-- | lib/backup/manager.rb | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index 1a4f28d106d..c6087830b40 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -11,28 +11,27 @@ module Backup s[:tar_version] = tar_version tar_file = "#{s[:backup_created_at].to_i}_gitlab_backup.tar" - orig_pwd = Dir.pwd - Dir.chdir(Gitlab.config.backup.path) + Dir.chdir(Gitlab.config.backup.path) do + File.open("#{Gitlab.config.backup.path}/backup_information.yml", + "w+") do |file| + file << s.to_yaml.gsub(/^---\n/,'') + end - File.open("#{Gitlab.config.backup.path}/backup_information.yml", "w+") do |file| - file << s.to_yaml.gsub(/^---\n/,'') - end + FileUtils.chmod_R(0700, %w{db uploads repositories}) - FileUtils.chmod_R(0700, %w{db uploads repositories}) + # create archive + $progress.print "Creating backup archive: #{tar_file} ... " + orig_umask = File.umask(0077) + if Kernel.system('tar', '-cf', tar_file, *BACKUP_CONTENTS) + $progress.puts "done".green + else + puts "creating archive #{tar_file} failed".red + abort 'Backup failed' + end + File.umask(orig_umask) - # create archive - $progress.print "Creating backup archive: #{tar_file} ... " - orig_umask = File.umask(0077) - if Kernel.system('tar', '-cf', tar_file, *BACKUP_CONTENTS) - $progress.puts "done".green - else - puts "creating archive #{tar_file} failed".red - abort 'Backup failed' + upload(tar_file) end - File.umask(orig_umask) - - upload(tar_file) - Dir.chdir(orig_pwd) end def upload(tar_file) |