Commit 36f3de4f59313c2f3582dd65f802b9ebf92e6bb9

Authored by Jacob Vosmaer
1 parent a540ab42

Remove duplication in Backup::Manager

Showing 1 changed file with 4 additions and 2 deletions   Show diff stats
lib/backup/manager.rb
1 module Backup 1 module Backup
2 class Manager 2 class Manager
  3 + BACKUP_CONTENTS = %w{repositories/ db/ uploads/ backup_information.yml}
  4 +
3 def pack 5 def pack
4 # saving additional informations 6 # saving additional informations
5 s = {} 7 s = {}
@@ -16,7 +18,7 @@ module Backup @@ -16,7 +18,7 @@ module Backup
16 18
17 # create archive 19 # create archive
18 print "Creating backup archive: #{s[:backup_created_at].to_i}_gitlab_backup.tar ... " 20 print "Creating backup archive: #{s[:backup_created_at].to_i}_gitlab_backup.tar ... "
19 - if Kernel.system(*%W(tar -cf #{s[:backup_created_at].to_i}_gitlab_backup.tar repositories/ db/ uploads/ backup_information.yml)) 21 + if Kernel.system('tar', '-cf', "#{s[:backup_created_at].to_i}_gitlab_backup.tar", *BACKUP_CONTENTS)
20 puts "done".green 22 puts "done".green
21 else 23 else
22 puts "failed".red 24 puts "failed".red
@@ -25,7 +27,7 @@ module Backup @@ -25,7 +27,7 @@ module Backup
25 27
26 def cleanup 28 def cleanup
27 print "Deleting tmp directories ... " 29 print "Deleting tmp directories ... "
28 - if Kernel.system(*%W(rm -rf repositories/ db/ uploads/ backup_information.yml)) 30 + if Kernel.system('rm', '-rf', *BACKUP_CONTENTS)
29 puts "done".green 31 puts "done".green
30 else 32 else
31 puts "failed".red 33 puts "failed".red