From ad25ef1f0d7e85e2b9797f30721caab00f62dfc2 Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Mon, 15 Jan 2018 20:33:35 +0530 Subject: List available backups for restore --- lib/backup/manager.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/backup') diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index 05aa79dc160..c6c6fca6b74 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -108,7 +108,12 @@ module Backup $progress.puts "Please make sure that file name ends with #{FILE_NAME_SUFFIX}" exit 1 elsif backup_file_list.many? && ENV["BACKUP"].nil? - $progress.puts 'Found more than one backup, please specify which one you want to restore:' + $progress.puts 'Found more than one backup:' + # print list of available backups + backup_file_list.each do |item| + $progress.puts " " + item.gsub("#{FILE_NAME_SUFFIX}", "") + end + $progress.puts 'Please specify which one you want to restore:' $progress.puts 'rake gitlab:backup:restore BACKUP=timestamp_of_backup' exit 1 end -- cgit v1.2.1 From 5a8cf78d5141406bdf6dbfa509b345612323d919 Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Mon, 15 Jan 2018 23:52:00 +0530 Subject: Move conditional to a separate method --- lib/backup/manager.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/backup') diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index c6c6fca6b74..f27ce4d2b2b 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -110,9 +110,7 @@ module Backup elsif backup_file_list.many? && ENV["BACKUP"].nil? $progress.puts 'Found more than one backup:' # print list of available backups - backup_file_list.each do |item| - $progress.puts " " + item.gsub("#{FILE_NAME_SUFFIX}", "") - end + $progress.puts " " + available_timestamps.join("\n ") $progress.puts 'Please specify which one you want to restore:' $progress.puts 'rake gitlab:backup:restore BACKUP=timestamp_of_backup' exit 1 @@ -174,6 +172,10 @@ module Backup @backup_file_list ||= Dir.glob("*#{FILE_NAME_SUFFIX}") end + def available_timestamps + @backup_file_list.map {|item| item.gsub("#{FILE_NAME_SUFFIX}", "")} + end + def connect_to_remote_directory(connection_settings) # our settings use string keys, but Fog expects symbols connection = ::Fog::Storage.new(connection_settings.symbolize_keys) -- cgit v1.2.1