Class: RestoreApp
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- RestoreApp
- Includes:
- DockerMgr::Util, Thor::Actions
- Defined in:
- lib/commands/restore_app.rb
Instance Method Summary collapse
Methods included from DockerMgr::Util
#add_line_to_routine, #add_packages, #add_trust, #admin_dir, #apps_dir, #attic_dir, #backup_dir, #base_images_dir, #cert_dir, #config, #data_services, #exec_hook, #extract_date, #extract_email, #extract_git_variable, #extract_name, #generate_ca_installer, #install_dir, #package_tar, #proxy_dir, #remove_line_from_routine, #root_dir, #root_dir_condition, #routine_dir, #runner_dir, #service_hooks_for, #services, #vhost_dir, #volumes
Instance Method Details
#restore ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/commands/restore_app.rb', line 13 def restore app_backup_dir = "#{backup_dir}/#{app_name}" app_backup_tmp_dir = "#{app_backup_dir}/tmp" reverse_sorted_entries = Dir.entries(app_backup_dir) .select {|entry| entry != "." && entry != ".."} .sort {| a,b | extract_date(b) <=> extract_date(a)} puts "please select your backup" reverse_sorted_entries.each_with_index{|entry,i| puts "#{i+1} #{entry}"} puts "(a) abort" choice = STDIN.gets.chomp abort "aborting" unless %w(1 2 3).include? choice chosen_backup = reverse_sorted_entries[choice.to_i - 1] choice = yes?("do you want to restore the data-container back to #{Time.at(extract_date(chosen_backup).to_i).strftime '%d.%m.%Y-%H:%M:%S'} (y,N)") abort "aborting" unless choice puts `tar -zxf #{app_backup_dir}/#{chosen_backup} -C #{app_backup_dir}` FileUtils.cd "#{apps_dir}/#{@app_name}" do puts 'executing before_all hook' puts exec_hook(@app_name,"restore","before_all") service_hooks_for(@app_name,"restore").each do |service| script_path = "#{apps_dir}/#{@app_name}/administration/hooks/restore.d/#{service}" puts "executing #{script_path}" Open3.popen3("#{script_path} #{app_backup_tmp_dir}/#{service} 2>&1") do |i,o,e,th| while line = o.gets do puts line end end end puts 'executing after_all hook' puts exec_hook(@app_name,"restore","after_all") end `rm -rf #{app_backup_tmp_dir}` end |