diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2014-10-02 09:28:23 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2014-10-02 09:28:23 +0000 |
commit | 2478fecae64000107535236febf2984315ab894a (patch) | |
tree | 621926958cd50219e36efc4329af3f016f72fe6f /lib | |
parent | b0349915e2615617aff9c5291f7e305d59ea3992 (diff) | |
parent | 02bf992f378f8b56ec7e698b5d603ded895dd0a4 (diff) | |
download | gitlab-ce-2478fecae64000107535236febf2984315ab894a.tar.gz |
Merge branch 'backup_fail_hard' into 'master'
Fail harder in the backup script
See merge request !1143
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backup/database.rb | 2 | ||||
-rw-r--r-- | lib/backup/manager.rb | 3 | ||||
-rw-r--r-- | lib/backup/repository.rb | 23 |
3 files changed, 22 insertions, 6 deletions
diff --git a/lib/backup/database.rb b/lib/backup/database.rb index 7b6908ccad8..d12d30a9110 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -21,6 +21,7 @@ module Backup system('pg_dump', config['database'], out: db_file_name) end report_success(success) + abort 'Backup failed' unless success end def restore @@ -37,6 +38,7 @@ module Backup system('psql', config['database'], '-f', db_file_name) end report_success(success) + abort 'Restore failed' unless success end protected diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index 908f10a4138..03fe0f0b02f 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -23,6 +23,7 @@ module Backup puts "done".green else puts "failed".red + abort 'Backup failed' end upload(tar_file) @@ -44,6 +45,7 @@ module Backup puts "done".green else puts "failed".red + abort 'Backup failed' end end @@ -53,6 +55,7 @@ module Backup puts "done".green else puts "failed".red + abort 'Backup failed' end end diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index ea05fa2c261..4e99d4bbe5c 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -15,10 +15,15 @@ module Backup if project.empty_repo? puts "[SKIPPED]".cyan - elsif system(*%W(git --git-dir=#{path_to_repo(project)} bundle create #{path_to_bundle(project)} --all), silent) - puts "[DONE]".green else - puts "[FAILED]".red + output, status = Gitlab::Popen.popen(%W(git --git-dir=#{path_to_repo(project)} bundle create #{path_to_bundle(project)} --all)) + if status.zero? + puts "[DONE]".green + else + puts "[FAILED]".red + puts output + abort 'Backup failed' + end end wiki = ProjectWiki.new(project) @@ -27,10 +32,14 @@ module Backup print " * #{wiki.path_with_namespace} ... " if wiki.empty? puts " [SKIPPED]".cyan - elsif system(*%W(git --git-dir=#{path_to_repo(wiki)} bundle create #{path_to_bundle(wiki)} --all), silent) - puts " [DONE]".green else - puts " [FAILED]".red + output, status = Gitlab::Popen.popen(%W(git --git-dir=#{path_to_repo(wiki)} bundle create #{path_to_bundle(wiki)} --all)) + if status.zero? + puts " [DONE]".green + else + puts " [FAILED]".red + abort 'Backup failed' + end end end end @@ -54,6 +63,7 @@ module Backup puts "[DONE]".green else puts "[FAILED]".red + abort 'Restore failed' end wiki = ProjectWiki.new(project) @@ -64,6 +74,7 @@ module Backup puts " [DONE]".green else puts " [FAILED]".red + abort 'Restore failed' end end end |