diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-11-07 19:36:43 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-11-07 19:36:43 +0300 |
commit | 396f45ade1dddec36df9861f8a1bb80aabd2ff15 (patch) | |
tree | 19ccb480337dd84926aaf3a7b16fe201f7ad0ce5 /lib | |
parent | cc175278467118585e86a8a425715a4e5ae62c95 (diff) | |
parent | 734fab8a6bf4d125ae13f53759d20810939def3b (diff) |
Merge branch '39903-restore-backup-warning' into 'master'
Make restoring backup database table warning more explicit
Closes #39903
See merge request gitlab-org/gitlab-ce!15246
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/gitlab/backup.rake | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index 1650263b98d..9dcf44fdc3e 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -33,24 +33,29 @@ namespace :gitlab do backup.unpack unless backup.skipped?('db') - unless ENV['force'] == 'yes' - warning = <<-MSG.strip_heredoc - Before restoring the database we recommend removing all existing - tables to avoid future upgrade problems. Be aware that if you have - custom tables in the GitLab database these tables and all data will be - removed. - MSG - puts warning.color(:red) - ask_to_continue - puts 'Removing all tables. Press `Ctrl-C` within 5 seconds to abort'.color(:yellow) - sleep(5) + begin + unless ENV['force'] == 'yes' + warning = <<-MSG.strip_heredoc + Before restoring the database, we will remove all existing + tables to avoid future upgrade problems. Be aware that if you have + custom tables in the GitLab database these tables and all data will be + removed. + MSG + puts warning.color(:red) + ask_to_continue + puts 'Removing all tables. Press `Ctrl-C` within 5 seconds to abort'.color(:yellow) + sleep(5) + end + # Drop all tables Load the schema to ensure we don't have any newer tables + # hanging out from a failed upgrade + $progress.puts 'Cleaning the database ... '.color(:blue) + Rake::Task['gitlab:db:drop_tables'].invoke + $progress.puts 'done'.color(:green) + Rake::Task['gitlab:backup:db:restore'].invoke + rescue Gitlab::TaskAbortedByUserError + puts "Quitting...".color(:red) + exit 1 end - # Drop all tables Load the schema to ensure we don't have any newer tables - # hanging out from a failed upgrade - $progress.puts 'Cleaning the database ... '.color(:blue) - Rake::Task['gitlab:db:drop_tables'].invoke - $progress.puts 'done'.color(:green) - Rake::Task['gitlab:backup:db:restore'].invoke end Rake::Task['gitlab:backup:repo:restore'].invoke unless backup.skipped?('repositories') |