From 24550f6bd2cc7aa656907123a136feeb6c03d233 Mon Sep 17 00:00:00 2001 From: Paulo Tada Date: Wed, 18 Nov 2015 14:12:23 -0200 Subject: [PATCH] Adding task create a dev env backups --- Rakefile | 1 + tasks/backups.rake | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-) create mode 100644 tasks/backups.rake diff --git a/Rakefile b/Rakefile index 9cfa569..86f4134 100644 --- a/Rakefile +++ b/Rakefile @@ -98,6 +98,7 @@ task :backup => ssh_config_file do end task :restore => [ssh_config_file, config_file] do + Rake::Task['devbackup'].invoke if $SPB_ENV!="prod" # setup sh 'ssh', '-F', ssh_config_file, 'integration', 'sudo', 'rm -rf /tmp/backups' sh 'ssh', '-F', ssh_config_file, 'integration', 'sudo', 'systemctl stop colab' diff --git a/tasks/backups.rake b/tasks/backups.rake new file mode 100644 index 0000000..c862b66 --- /dev/null +++ b/tasks/backups.rake @@ -0,0 +1,32 @@ +desc "This task will change the emails from backups" + +$REMOVE_SCRIPT="remove_backup_email.py" +$REMOVE_SCRIPT_DIR="utils/#{$REMOVE_SCRIPT}" +$BACKUPS_DIR="backups/" + +task :devbackup do + puts "You're NOT in a prod environment" + puts "This will alter all the emails." + puts "Do you want to alter the backups? [Y/n]" + if confirmed + sh 'cp' , "#{$REMOVE_SCRIPT_DIR}" , "#{$BACKUPS_DIR}" + sh "cd #{$BACKUPS_DIR} && python #{$REMOVE_SCRIPT}" + end +end + +def confirmed + STDOUT.flush + input = STDIN.gets.chomp + case input.upcase + when "Y", "" + puts "Altering emails from backups..." + return true + when "N" + puts "Aborting remove email backups..." + puts "Restoring with a normal backups" + return false + else + puts "Please enter Y or N" + get_confirmation + end +end -- libgit2 0.21.2