irgat 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,4 +82,4 @@ if @console.config_module[:load_modules] == "all"
82
82
  }
83
83
  end
84
84
 
85
- puts "** Console enable modules => #{ enable_modules.join(', ') }"
85
+ puts "** Console enable modules => #{ enable_modules.join(', ') }"
@@ -17,9 +17,9 @@ module Irgat
17
17
  @programs = Hash.new
18
18
  programs.each { |p|
19
19
  # locate program
20
- program_path = %x[ which #{p} ]
21
- if program_path
22
- @programs[p.to_sym] = program_path.strip
20
+ program_path = execute_command("which #{ p }","Where is #{ p } program", { :debug => 3 })
21
+ if program_path[:output]
22
+ @programs[p.to_sym] = program_path[:output].strip
23
23
  else
24
24
  exit_with_error("Irgat couldn't find the program #{ p } needed by #{ self.class } module")
25
25
  end
@@ -45,20 +45,25 @@ module Irgat
45
45
  end
46
46
 
47
47
  def check_mounted_folder(folder)
48
- mount_points = execute_command("mount","Getting mount points")
49
- if mount_points.include?(folder)
48
+ mount_points = execute_command("mount",
49
+ "Getting mount points",
50
+ { :debug => 3 })
51
+ if mount_points[:output].include?(folder)
50
52
  log("text","OK. #{folder} already mounted")
51
53
  else
52
54
  # we try to mount
53
- log("text","Warning. #{folder} not mounted. Triying to mount")
55
+ log("text", "Warning. #{folder} not mounted. Triying to mount", 2)
54
56
  execute_command("mount #{folder}",
55
57
  "Mounting working directory #{folder}",
56
- {:fatal_error => true})
58
+ {:fatal_error => true, :debug => 3 })
57
59
  end
58
60
  end
59
61
 
60
62
  def check_egid(user)
61
- if user != execute_command("whoami", "Getting irgat launcher user", 3).strip
63
+ command = execute_command("whoami",
64
+ "Getting irgat launcher user",
65
+ { :debug => 3 })
66
+ if user != command[:output].strip
62
67
  exit_with_error("#{ @config_module[:subsystem_name] } Irgat module must run as #{ user } User")
63
68
  end
64
69
  end
@@ -67,7 +72,7 @@ module Irgat
67
72
  def exist_or_create_folder(folder_absolute_path)
68
73
  if ! test(?d,folder_absolute_path)
69
74
  Dir.mkdir(folder_absolute_path)
70
- log("text", "Creating folder #{ folder_absolute_path }", 2)
75
+ log("text", "Creating folder #{ folder_absolute_path }", 3)
71
76
  end
72
77
  end
73
78
 
@@ -4,66 +4,63 @@ module Irgat
4
4
  module Execs
5
5
 
6
6
  def execute_command(command, command_description, options = {})
7
- @commands_launched ||= Hash.new
7
+ @commands_launched ||= Array.new
8
8
 
9
- command_exec = command.to_s
10
- pre_command_time = Time.now
11
- command_output = %x[ #{command_exec} 2> /tmp/error_out ]
12
- finish_status = $?
13
- pos_command_time = Time.now
14
- error_output = File.new("/tmp/error_out").read
9
+ command_data = Hash.new
10
+
11
+ command_data[:info] = command_description
12
+ command_data[:exec] = command.to_s
13
+ command_data[:pre_time] = Time.now
14
+ command_data[:output] = %x[ #{command_data[:exec]} 2> /tmp/error_out ]
15
+ command_data[:status] = $?
16
+ command_data[:pos_time] = Time.now
17
+ command_data[:errors] = File.new("/tmp/error_out").read
18
+
19
+ # add to commands launched
20
+ @commands_launched << { command_data[:info] => command_data[:status] }
15
21
 
16
22
  # exit?
17
- if finish_status != 0 && options[:fatal_error]
23
+ if command_data[:status] != 0 && options[:fatal_error]
18
24
  debug_mode = "\n"
19
- debug_mode << "\n [ Command Syntax ] => #{ command_exec }"
20
- debug_mode << "\n [ Command Output ] => #{ command_output }"
21
- debug_mode << "\n [ Command Errors ] => #{ error_output }"
25
+ debug_mode << "\n [ Command Syntax ] => #{ command_data[:exec] }"
26
+ debug_mode << "\n [ Command Output ] => #{ command_data[:output] }"
27
+ debug_mode << "\n [ Command Errors ] => #{ command_data[:errors] }"
22
28
 
23
- exit_with_error("Command '#{ command_description }' exit with a #{ finish_status } status. Error is reported as FATAL, then, exit Irgat process. #{ debug_mode if @config[:debug_level] == 3 }")
29
+
30
+ exit_with_error("Command '#{ command_data[:info] }' exit with a #{ command_data[:status] } status. Error is reported as FATAL, then, exit Irgat process. #{ debug_mode if @config[:debug_level] == 3 }", { :exit_level => 6 })
24
31
  end
25
32
 
26
33
  # Log the outputs || debug 1
27
- log("command", "* [#{ (finish_status == 0 ? " OK " : " WARNING") }: #{Time.now.strftime("%H:%M:%S")}] -> #{ command_description }", 1)
34
+ log("command", "* [#{ (command_data[:status] == 0 ? " OK " : " WARNING") }: #{Time.now.strftime("%H:%M:%S")}] -> #{ command_data[:info] }", 1) unless options[:debug] == 2 || options[:debug] == 3
28
35
 
29
36
  # Log warning level
30
- if finish_status != 0
31
- log("warning", "Command #{ command_description } exited with a #{ finish_status } status.", 2)
37
+ if command_data[:status] != 0
38
+ log("warning", " ** Command #{ command_data[:info] } exited with a #{ command_data[:status] } status.", 2)
32
39
  end
33
40
 
34
41
  # Log 3 level... commands launched and reports
35
- text_to_log = "\n ** [COMMAND LOG]"
36
- text_to_log << "\n [ Command Syntax ] => #{ command_exec }"
37
- text_to_log << "\n [ Command Status ] => #{ finish_status }"
38
- text_to_log << "\n [ Command Output ] => #{ command_output }"
39
- text_to_log << "\n [ Command Errors ] => #{ error_output }"
40
- text_to_log << "\n [ Command P.Time ] => #{ pos_command_time - pre_command_time }\n\n"
42
+ text_to_log = "\n *** [COMMAND LOG]"
43
+ text_to_log << "\n [ Command Syntax ] => #{ command_data[:exec] }"
44
+ text_to_log << "\n [ Command Status ] => #{ command_data[:status] }"
45
+ text_to_log << "\n [ Command Output ] => #{ command_data[:output] }"
46
+ text_to_log << "\n [ Command Errors ] => #{ command_data[:errors] }"
47
+ text_to_log << "\n [ Command P.Time ] => #{ command_data[:pos_time] - command_data[:pre_time] }\n\n"
41
48
 
42
49
  log("text", text_to_log, 3)
43
50
 
44
- # add the command to the commands_launched hash
45
- @commands_launched[command_description] = finish_status
46
-
47
- return command_output
51
+ return command_data
48
52
  end
49
53
 
50
- # method to end irgat process and report
51
- def finish_process(options = {})
52
- output_options = Hash.new
53
- output_options[:fatal] = options[:fatal] || false
54
- output_options[:main_msj] = options[:msj] || "Finish Process"
55
- # output the logs
56
- output_log({ :fatal => output_options[:fatal],
57
- :main_msj => output_options[:main_msj] })
58
- end
59
54
 
60
55
  # Exit irgat process with error and optional exit status
61
56
  def exit_with_error(msj, options = {})
62
-
63
- log("text", msj, 1)
64
-
65
- finish_process( { :fatal => true, :msj => "Exit with error #{ msj }" } ) unless options[:no_finish_process]
66
-
57
+ log("error", msj, 1)
58
+
59
+
60
+ output_log(self,
61
+ { :main_msj => "[IRGAT] [#{ self.config_module[:subsystem_name].capitalize }] [ERROR] #{ self.action } process in #{ @config[:server_name] }",
62
+ :fatal => true })
63
+
67
64
  exit (options[:exit_level] ? options[:exit_level] : 1)
68
65
  end
69
66
 
@@ -3,47 +3,49 @@
3
3
  module Irgat
4
4
  module Log
5
5
 
6
+ # Store the output messages in a class array variable
6
7
  def log(output_type, message, debug = nil)
7
- # create @log_process if not exist or use it
8
8
  @log_process ||= Array.new
9
9
  # add new hash to point variable
10
10
  log_point = Hash.new
11
11
  log_point[:type] = output_type
12
12
  log_point[:msj] = message
13
- log_point[:debug] = debug || 3
13
+ log_point[:debug] = debug.to_i || 3 # highter level if not marked
14
14
  @log_process << log_point
15
- # need to puts
16
15
 
17
- if @log_to_stdout && @config[:debug_level] >= log_point[:debug]
18
- puts "[#{ log_point[:type] }] \n #{ log_point[:msj] }"
16
+ # to stodout
17
+ unless @config[:debug_level].to_i < log_point[:debug]
18
+ puts colorize(log_point)
19
19
  end
20
20
  end
21
21
 
22
- def output_log(options = {})
22
+ def output_log(module_process, options = {})
23
+
23
24
  fatal = options[:fatal] || false
24
25
 
25
26
  # build report
26
- report = build_report
27
- resume = build_resume(fatal)
27
+ report = build_report(module_process.log_process)
28
+ resume = build_resume(fatal, module_process)
28
29
 
29
- if @config_module[:output_log]
30
- # add a extend header to the log report
31
- report_to_log(report)
30
+ # output to email or log file
31
+ if module_process.config_module[:log_file_actions].include?(module_process.action)
32
+ report_to_log(report, module_process)
32
33
  end
33
34
 
34
- if @config_module[:output_email]
35
+ if module_process.config_module[:log_file_actions].include?(module_process.action)
35
36
  report_to_email(resume, report, options[:main_msj] )
36
37
  end
38
+
37
39
  end
38
40
 
39
- def report_to_log(report)
41
+ def report_to_log(report, module_process)
40
42
  exist_or_create_folder(@config[:log_path])
41
43
 
42
- log_file_folder = "#{ @config[:log_path] }/#{ @config_module[:subsystem_name] }"
44
+ log_file_folder = "#{ @config[:log_path] }/#{ module_process.config_module[:subsystem_name] }"
43
45
 
44
46
  exist_or_create_folder(log_file_folder)
45
47
 
46
- log_file = "#{ log_file_folder }/#{ Time.now.strftime("%Y-%m-%d") }_#{ @config[:server_name] }.log"
48
+ log_file = "#{ log_file_folder }/#{ Time.now.strftime("%Y-%m-%d") }_#{ module_process.action }_in_#{ @config[:server_name] }.log"
47
49
 
48
50
  if log_out = File.new(log_file,"w+")
49
51
  log_out.puts report
@@ -62,15 +64,16 @@ module Irgat
62
64
  send_email({ :subject => subject, :body => resume })
63
65
  end
64
66
 
65
- def build_report
67
+ private
68
+ def build_report(log_process)
66
69
  report = ''
67
70
 
68
- @log_process.each { |log_entry|
71
+ log_process.each { |log_entry|
69
72
  case log_entry[:type]
70
73
  when "point"
71
74
  @point ||= 0
72
75
  underscroll_caracter = "="
73
- report << "\n #{ @point } #{ log_entry[:msj] } \n"
76
+ report << "\n\n #{ @point } #{ log_entry[:msj] } \n"
74
77
  report << ' ' + (underscroll_caracter * @point.to_s.length) + underscroll_caracter + (underscroll_caracter * log_entry[:msj].length) + "\n"
75
78
  @point += 1
76
79
  when "text"
@@ -79,7 +82,7 @@ module Irgat
79
82
  end
80
83
  when "command"
81
84
  if @config[:debug_level] >= log_entry[:debug]
82
- report << "\n\n #{ log_entry[:msj] }"
85
+ report << "\n #{ log_entry[:msj] }"
83
86
  end
84
87
  end
85
88
  }
@@ -87,11 +90,9 @@ module Irgat
87
90
  end
88
91
 
89
92
  # method to report a info of the irgat process
90
- def build_resume(fatal)
91
-
92
-
93
+ def build_resume(fatal,module_process)
93
94
  total_time = Time.now - @init_time
94
- total_time_log = "#{ total_time.to_s.slice(0,5) } sec., #{ (total_time / 60).to_s.slice(0,5) } min., #{ ((total_time / 60) / 60).to_s.slice(0,5) } hours."
95
+ total_time_log = "#{ total_time.to_s.slice(0,5) } sec., #{ (total_time / 60).to_s.slice(0,5) } min., #{ ((total_time / 60) / 60).to_int.to_s.slice(0,5) } hours."
95
96
  fatal_log = (fatal ? "ERROR" : "OK")
96
97
 
97
98
  report_resume = "\n"
@@ -100,17 +101,49 @@ module Irgat
100
101
  report_resume << "\n"
101
102
  report_resume << " * Resume info \n"
102
103
  report_resume << " [ Serv Host ] -> #{ @config[:server_name] } \n"
103
- report_resume << " [ Module ] -> #{ self.class.to_s } \n"
104
+ report_resume << " [ Module ] -> #{ module_process.config_module[:subsystem_name].capitalize } \n"
104
105
  report_resume << " [ Init Time ] -> #{ @init_time } \n"
105
106
  report_resume << " [ End Time ] -> #{ Time.now } \n"
106
107
  report_resume << " [ TotalTime ] -> #{ total_time_log } \n"
107
- if @commands_launched
108
- report_resume << " [ CmdsExecs ] -> #{ @commands_launched.values.select { |v| v == 0 }.size } \n"
109
- report_resume << " [ Warnings ] -> #{ @commands_launched.values.select { |v| v != 0 }.size} \n"
108
+ if module_process.commands_launched
109
+ report_resume << " [ CmdsExecs ] -> #{ module_process.commands_launched.select { |v| v.values.to_s == "0" }.size } \n"
110
+ report_resume << " [ Warnings ] -> #{ module_process.commands_launched.select { |v| v.values.to_s != "0" }.size} \n"
111
+ end
112
+
113
+ if fatal
114
+ report_resume << "\n [ **FATAL** ] -> Irgat Process ended in command: '#{ module_process.commands_launched.last.keys.to_s }'"
110
115
  end
111
116
 
112
117
  return report_resume
113
118
  end
114
119
 
120
+ def colorize(log_entry)
121
+ case log_entry[:type]
122
+ when "text"
123
+ return_msj = "\x1b[#{ 38 };5;#{ 244 }m#{ log_entry[:msj] }\x1b[0m"
124
+ when "error"
125
+ return_msj = "\n \x1b[#{ 38 };5;#{ 160 }m#{ "ERROR!!" } \x1b[0m" + log_entry[:msj].gsub(/#{ "FATAL" }/, "\x1b[#{38};5;#{ 160 }m#{ "*FATAL*" }\x1b[0m")
126
+ when "warning"
127
+ return_msj = "\x1b[#{ 38 };5;#{ 240 }m#{ log_entry[:msj] }\x1b[0m"
128
+ when "point"
129
+ return_msj = "\n\x1b[#{ 48 };5;#{ 252 }m#{ log_entry[:msj] }\x1b[0m \n"
130
+ when "command"
131
+ if log_entry[:msj]["OK"]
132
+ color = 2
133
+ text = "OK"
134
+ elsif log_entry[:msj]["WARNING"]
135
+ color = 220
136
+ text = "WARNING"
137
+ elsif log_entry[:msj]["ERROR"]
138
+ color = 160
139
+ text = "ERROR"
140
+ elsif log_entry[:msj]["FATAL"]
141
+ color = 160
142
+ text = "FATAL"
143
+ end
144
+ return_msj = log_entry[:msj].gsub(/#{ text }/, "\x1b[#{38};5;#{ color }m#{ text }\x1b[0m")
145
+ end
146
+ return_msj
147
+ end
115
148
  end
116
149
  end
@@ -7,6 +7,7 @@
7
7
  begin
8
8
  # require all the irgat utils
9
9
  # FIXME atd wants includes in irgat.
10
+ require 'irgat/help'
10
11
  require 'irgat/log'
11
12
  require 'irgat/mail'
12
13
  require 'irgat/execs'
@@ -1,10 +1,15 @@
1
1
  module Irgat
2
- module VERSION #:nodoc:
2
+ module Version #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
- self
8
+
9
+ class << self
10
+ def to_s
11
+ STRING
12
+ end
13
+ end
9
14
  end
10
15
  end
@@ -17,7 +17,8 @@ module Irgat
17
17
  class Backup < Irgat
18
18
 
19
19
  # initialize the Class... make default operations
20
- def initialize
20
+ def initialize(values = {})
21
+ @action = values[:action]
21
22
  # Create and irgat process
22
23
  irgat_process = Irgat.new()
23
24
  # Get the instance variables
@@ -37,23 +38,66 @@ module Irgat
37
38
  @config_module[:folders_tree] ],
38
39
  :check_egid => @config_module[:run_as_user]
39
40
  )
40
-
41
41
  end
42
42
 
43
43
  def default(args = {})
44
- # no default action in backup module, show help
45
- puts 'FIXME * action needed'
44
+ exit_with_error("\n ** [ ERROR ] No default action for Backup Module. Avaible methods: \n list, search, restore, launch", { :exit_level => 7 })
46
45
  end
47
46
 
48
47
  def list(args = [])
49
- puts list_catalog
48
+ log("text", list_catalog[:output])
49
+ end
50
+
51
+ def search(args = [])
52
+ if args.include?('-c')
53
+ args.delete('-c')
54
+ result = search_complete(args.first)
55
+ if !result.empty?
56
+ text = "\n * The pattern match in: \n\n"
57
+ text << "#{ result }"
58
+ text << "\n * Restore the file with $ irgat backup restore <number backup> <file name>\n File will be restored in #{ @folders[:restore] }/<file name> }"
59
+ log("text", text, 1)
60
+ else
61
+ exit_with_error(" ** [ ERROR ] not pattern found.\n Exit", { :exit_level => 3} )
62
+ end
63
+ else
64
+ result = search_file(args.first)
65
+ if result[:status] == 0
66
+ text = "\n * The file exist in these backups \n\n"
67
+ text << "#{ result[:output] }"
68
+ text << "\n * Restore the file with $ irgat backup restore <number backup> <file>\n File will be restored in #{ @folders[:restore] }/<file> }"
69
+ log("text", text, 1)
70
+
71
+ else
72
+ exit_with_error(" ** [ ERROR ] not file found.\n Use $ irgat backup search <file> with -c option for a complete search", { :exit_level => 3} )
73
+ end
74
+ end
75
+ end
76
+
77
+ def restore(args = [])
78
+ backup_number = args[0] || nil
79
+ restore_file = args[1] || nil
80
+ if !backup_number or !restore_file
81
+ exit_with_error(" ** [ ERROR] Not Backup or restore file passed. Syntax is $ irgat backup restore <number of backup> <file to restore>", { :exit_level => 7 })
82
+ else
83
+ # identify backup file
84
+ if ( !backup_data = get_backup_data(backup_number))
85
+ exit_with_error(" ** [ ERROR ] Backup '#{ backup_number }' not found in catalog", { :exit_level => 3 })
86
+ else
87
+ # try to restore
88
+ restore_command = "#{ @programs[:dar] } -x #{ backup_data[:file] } -R #{ @folders[:restore] } -K '#{ @config_module[:dar]["decrypt_passwd"] }' -v -g '#{ restore_file }'"
89
+ result = execute_command(
90
+ restore_command,
91
+ "Restoring file",
92
+ { :fatal_error => true })
93
+ log("text"," Files were succesfull restored", 1)
94
+ end
95
+ end
50
96
  end
51
97
 
52
98
  def launch(args = [])
53
- # @backup.set_log_output_to_file
54
99
  log("point", "Init Irgat Backup Launch")
55
100
 
56
- # mysql dumps? FIXME to bbdd_dumps?
57
101
  if @config_module[:dump_mysql]
58
102
  log("point","Doing MySQL database Dumping")
59
103
  do_mysql_dumps
@@ -62,8 +106,8 @@ module Irgat
62
106
  # use the specific backup program
63
107
  self.send("do_backup_with_" + @config_module[:backup_program])
64
108
 
65
- # finish process
66
- finish_process({ :msj => "[IRGAT] [BACKUP] [OK] Backup Launch in #{ @config[:server_name] } server" })
109
+ # finish process || return STRING
110
+ return "[IRGAT] [BACKUP] [OK] Backup Launch in #{ @config[:server_name] } server"
67
111
 
68
112
  end
69
113
 
@@ -83,7 +127,7 @@ module Irgat
83
127
  end
84
128
 
85
129
  # Each db, make dump and compress with gzip
86
- dbs.each { |db|
130
+ dbs[:output].each { |db|
87
131
  dump_file = "mysqldump_#{ Date.today }_#{db.chop}.sql"
88
132
  execute_command(
89
133
  "#{ @programs[:mysqldump] } -u #{ @config_module[:mysql_user] } -p#{ @config_module[:mysql_pass] } #{db.chop} -r #{dump_file}",
@@ -117,7 +161,7 @@ module Irgat
117
161
  dar_command = build_dar_command("do_backup", { "backup_type" => backup_type })
118
162
 
119
163
  # exec backup
120
- log("point", "Doing backup")
164
+ log("point", "Doing #{ backup_type.capitalize } Backup")
121
165
  execute_command(dar_command, "Doing #{ backup_type.capitalize } Backup")
122
166
 
123
167
  # test backup
@@ -245,8 +289,13 @@ module Irgat
245
289
  execute_command(
246
290
  command_list_catalog,
247
291
  "Listing backup in catalog")
292
+ execute_command(
293
+ "ls /tmpdede",
294
+ "Listing the kaka",
295
+ {:fatal_error => true })
248
296
  end
249
297
 
298
+
250
299
  def identifies_backups_in_catalog(pattern)
251
300
  ids_backups = []
252
301
  backups_in_catalog = list_catalog
@@ -257,33 +306,15 @@ module Irgat
257
306
  }
258
307
  return ids_backups
259
308
  end
260
-
261
- # end backups process... report state and send emails if is configured for
262
- def do_finish_backup(fatal = nil)
263
- # take a report for the backup process
264
- report = self.process_report
265
-
266
- # if email reporting is avaible, we have to send an email
267
- if @config_module[:report_email]
268
- #build subjetc
269
- if fatal
270
- subject_email="[IRGAT Backup] Fatal error in #{self.config[:server_name]}"
271
- else
272
- subject_email="[IRGAT Backup] Succesfull in #{self.config[:server_name]}"
273
- end
274
309
 
275
- # FIXME, wrap to litura... not good hear
276
- if self.config[:server_name]=='litura'
277
- self.send_email(:body=>report,:subject => subject_email, :in_chroot => true )
278
- else
279
- self.send_email(:body=>report,:subject => subject_email)
280
- end
281
-
310
+ def get_backup_data(num_backup)
311
+ backups = get_all_backups_in_catalog
312
+ for backup in backups
313
+ select_backup = backup if backup[:id] == num_backup
282
314
  end
283
- # write the report also to the file
284
- self.log("text",report,1)
315
+ select_backup
285
316
  end
286
-
317
+
287
318
  def create_catalog(catalog_file_name)
288
319
  create_catalog_command = @programs[:dar_manager] + ' -C ' + catalog_file_name
289
320
  execute_command(
@@ -292,6 +323,54 @@ module Irgat
292
323
  { :fatal_error => true })
293
324
  end
294
325
 
326
+ def search_complete(pattern)
327
+ backups = get_all_backups_in_catalog
328
+ catalog = @folders[:catalog] + '/catalog_' + @config[:server_name]
329
+
330
+ result = ""
331
+ for backup in backups
332
+ log("point", "Searching #{ pattern } in backup #{ backup[:file] }")
333
+ search_complete_command = "#{ @programs[:dar_manager] } -B #{ catalog } -u #{ backup[:id] }"
334
+ command = execute_command(
335
+ search_complete_command,
336
+ "Listing files in backup #{ backup[:file] }")
337
+ command[:output].each_line { |backup_lines|
338
+ if backup_lines.include?(pattern)
339
+ result << " - Backup number: #{ backup[:id] } (#{ backup[:file] }) -- File name: '#{ backup_lines.split(' ')[2] }'\n"
340
+ end
341
+ }
342
+ end
343
+ result
344
+ end
345
+
346
+
347
+ def search_file(pattern)
348
+ if !pattern
349
+ exit_with_error("\n ** Can't search without name file. Please type a file to search", { :exit_level => 7 })
350
+ end
351
+
352
+ catalog = @folders[:catalog] + '/catalog_' + @config[:server_name]
353
+ command_search_file = "#{ @programs[:dar_manager] } -B #{ catalog } -f '#{ pattern }'"
354
+ execute_command(
355
+ command_search_file,
356
+ "Searching file")
357
+ end
358
+
359
+ def get_all_backups_in_catalog()
360
+ backups = Array.new
361
+ # get all the backups in catalog and build variable
362
+ list_backups = list_catalog[:output]
363
+ list_backups.each_line { |backup_in_catalog|
364
+ if backup_in_catalog.strip =~ /^[0-9]/
365
+ backup = Hash.new
366
+ backup[:id] = backup_in_catalog.split(' ')[0]
367
+ backup[:file] = "#{ backup_in_catalog.split(' ')[1] }/#{ backup_in_catalog.split(' ')[2] }"
368
+ backups << backup
369
+ end
370
+ }
371
+ backups
372
+ end
373
+
295
374
  # FIXME
296
375
  def build_dar_command(for_what, options = {})
297
376
  # merge options with default
@@ -320,6 +399,9 @@ module Irgat
320
399
  for folder in @config_module[:exclude_folders]
321
400
  dar_command[:exclude_folders] << "-P #{folder} "
322
401
  end
402
+ ## add exclude data and restore folder
403
+ dar_command[:exclude_folders] << "-P #{ @folders[:restore][1..-1] } -P #{ @folders[:data][1..-1] } "
404
+
323
405
  dar_command[:exclude_files] = ''
324
406
  for extension in @config_module[:exclude_files]
325
407
  dar_command[:exclude_files] << "-X '*#{extension}' "