2 # Execute a backup on schedule
6 our (%text, %config, $no_acl_check);
8 require './backup-config-lib.pl';
9 &foreign_require("mailboxes", "mailboxes-lib.pl");
12 my $backup = &get_backup($ARGV[0]);
13 $backup || die "Failed to find backup $ARGV[0]";
15 # Run the pre-backup command, if any
18 if ($backup->{'pre'} =~ /\S/) {
19 my $preout = &backquote_command("($backup->{'pre'}) 2>&1 </dev/null");
20 $premsg = &text('email_pre', $backup->{'pre'})."\n".
23 $err = $text{'email_prefailed'};
28 my @mods = split(/\s+/, $backup->{'mods'});
31 $err = &execute_backup(\@mods, $backup->{'dest'}, \$size, undef,
32 $backup->{'configfile'}, $backup->{'nofiles'},
33 [ split(/\t+/, $backup->{'others'}) ]);
36 # Run the post-backup command, if any
38 if (!$err && $backup->{'post'} =~ /\S/) {
39 my $postout = &backquote_command("($backup->{'post'}) 2>&1 </dev/null");
41 &text('email_post', $backup->{'post'})."\n".
45 # Send off the results
46 if (($err || $backup->{'emode'} == 0) && $backup->{'email'}) {
48 foreach my $m (@mods) {
49 my %minfo = &get_module_info($m);
50 $mlist .= " $minfo{'desc'}\n";
52 my $host = &get_system_hostname();
53 my $nice = &nice_dest($backup->{'dest'}, 1);
54 $nice =~ s/<[^>]+>//g;
60 $text{'email_mods'}."\n".
63 &text('email_failed', $nice)."\n\n".
65 $subject = &text('email_sfailed', $host);
69 $text{'email_mods'}."\n".
72 &text('email_ok', $nice)."\n".
73 &text('email_final', &nice_size($size))."\n".
75 $subject = &text('email_sok', $host);
77 &mailboxes::send_text_mail($config{'from_addr'} ||
78 &mailboxes::get_from_address(),