Handle hostnames with upper-case letters
[webmin.git] / bacula-backup / gbackup.cgi
1 #!/usr/local/bin/perl
2 # Execute multiple backup jobs, one for each client
3
4 require './bacula-backup-lib.pl';
5 &ui_print_unbuffered_header(undef,  $text{'gbackup_title'}, "");
6 &ReadParse();
7
8 # Get the backup job def and real jobs
9 $conf = &get_director_config();
10 @jobdefs = &find("JobDefs", $conf);
11 $jobdef = &find_by("Name", "ocjob_".$in{'job'}, \@jobdefs);
12 foreach $job (&get_bacula_jobs()) {
13         ($j, $c) = &is_oc_object($job);
14         if ($j eq $in{'job'} && $c) {
15                 push(@jobs, $job);
16                 }
17         }
18
19 print "<b>",&text('gbackup_run', "<tt>$in{'job'}</tt>",
20                                  scalar(@jobs)),"</b>\n";
21
22 # Clear messages
23 $h = &open_console();
24 &console_cmd($h, "messages");
25
26 # Run the real jobs
27 print "<dl>\n";
28 foreach $job (@jobs) {
29         ($j, $c) = &is_oc_object($job);
30         print "<dt>",&text('gbackup_on', "<tt>$c</tt>"),"\n"; 
31         print "<dd><pre>";
32
33         # Select the job to run
34         &sysprint($h->{'infh'}, "run\n");
35         &wait_for($h->{'outfh'}, 'run\\n');
36         $rv = &wait_for($h->{'outfh'}, 'Select Job.*:');
37         print $wait_for_input;
38         if ($rv == 0 && $wait_for_input =~ /(\d+):\s+\Q$job->{'name'}\E/) {
39                 &sysprint($h->{'infh'}, "$1\n");
40                 }
41         else {
42                 &job_error($text{'backup_ejob'});
43                 }
44
45         # Say that it is OK
46         $rv = &wait_for($h->{'outfh'}, 'OK to run.*:');
47         print $wait_for_input;
48         if ($rv == 0) {
49                 &sysprint($h->{'infh'}, "yes\n");
50                 }
51         else {
52                 &job_error($text{'backup_eok'});
53                 }
54
55         print "</pre>";
56         }
57 print "</dl>\n";
58 &close_console($h);
59 &webmin_log("gbackup", $in{'job'});
60
61 &ui_print_footer("", $text{'index_return'});
62
63 sub job_error
64 {
65 print "</pre>\n";
66 print "<b>",@_,"</b><p>\n";
67 &close_console($h);
68 &ui_print_footer("backup_form.cgi", $text{'backup_return'});
69 exit;
70 }
71