#!/usr/local/bin/perl
# Do an immediate backup
+use strict;
+use warnings;
require './backup-config-lib.pl';
+our (%in, %text, %config, $module_config_file);
&ReadParse();
# Validate inputs
&error_setup($text{'backup_err'});
-$dest = &parse_backup_destination("dest", \%in);
-($configfile, $nofiles, $others) = &parse_backup_what("what", \%in);
-@mods = split(/\0/, $in{'mods'});
+my $dest = &parse_backup_destination("dest", \%in);
+my ($configfile, $nofiles, $others) = &parse_backup_what("what", \%in);
+my @mods = split(/\0/, $in{'mods'});
@mods || ($nofiles && !$configfile) || &error($text{'backup_emods'});
# Go for it
-($mode, $user, $pass, $server, $path, $port) = &parse_backup_url($dest);
+my ($mode, $user, $pass, $server, $path, $port) = &parse_backup_url($dest);
+my $err;
if ($mode != 4) {
# Save somewhere, and tell the user
&ui_print_header(undef, $text{'backup_title'}, "");
print &text('backup_doing', &nice_dest($dest, 1)),"<p>\n";
+ my $size;
+ my @files;
+ my @mods;
$err = &execute_backup(\@mods, $dest, \$size, \@files,
$configfile, $nofiles,
[ split(/\t+/, $others) ]);
}
else {
# Output file in browser
- $temp = &transname();
+ my $temp = &transname();
+ my $size;
+ my @mods;
$err = &execute_backup(\@mods, $temp, \$size, undef,
$configfile, $nofiles);
if ($err) {
&error($err);
}
print "Content-type: application/octet-stream\n\n";
+ my $buf;
open(TEMP, $temp);
while(read(TEMP, $buf, 1024)) {
print $buf;
#!/usr/local/bin/perl
# Execute a backup on schedule
+use strict;
+use warnings;
+our (%text, %config, $no_acl_check);
$no_acl_check++;
require './backup-config-lib.pl';
&foreign_require("mailboxes", "mailboxes-lib.pl");
# Get the backup
-$backup = &get_backup($ARGV[0]);
+my $backup = &get_backup($ARGV[0]);
$backup || die "Failed to find backup $ARGV[0]";
# Run the pre-backup command, if any
+my $err;
+my $premsg;
if ($backup->{'pre'} =~ /\S/) {
- $preout = &backquote_command("($backup->{'pre'}) 2>&1 </dev/null");
+ my $preout = &backquote_command("($backup->{'pre'}) 2>&1 </dev/null");
$premsg = &text('email_pre', $backup->{'pre'})."\n".
$preout."\n";
if ($?) {
}
# Do it
-@mods = split(/\s+/, $backup->{'mods'});
+my @mods = split(/\s+/, $backup->{'mods'});
+my $size;
if (!$err) {
$err = &execute_backup(\@mods, $backup->{'dest'}, \$size, undef,
$backup->{'configfile'}, $backup->{'nofiles'},
}
# Run the post-backup command, if any
+my $postmsg;
if (!$err && $backup->{'post'} =~ /\S/) {
- $postout = &backquote_command("($backup->{'post'}) 2>&1 </dev/null");
+ my $postout = &backquote_command("($backup->{'post'}) 2>&1 </dev/null");
$postmsg = "\n".
&text('email_post', $backup->{'post'})."\n".
$postout."\n";
# Send off the results
if (($err || $backup->{'emode'} == 0) && $backup->{'email'}) {
- foreach $m (@mods) {
- %minfo = &get_module_info($m);
+ my $mlist;
+ foreach my $m (@mods) {
+ my %minfo = &get_module_info($m);
$mlist .= " $minfo{'desc'}\n";
}
- $host = &get_system_hostname();
- $nice = &nice_dest($backup->{'dest'}, 1);
+ my $host = &get_system_hostname();
+ my $nice = &nice_dest($backup->{'dest'}, 1);
$nice =~ s/<[^>]+>//g;
$err =~ s/<[^>]+>//g;
+ my $msg;
+ my $subject;
if ($err) {
$msg = $premsg.
$text{'email_mods'}."\n".
$postmsg;
$subject = &text('email_sok', $host);
}
- print STDERR $msg,"\n";
&mailboxes::send_text_mail($config{'from_addr'} ||
&mailboxes::get_from_address(),
$backup->{'email'},
+use strict;
+use warnings;
do 'backup-config-lib.pl';
sub cgi_args
#!/usr/local/bin/perl
# Show one scheduled backup
+use strict;
+use warnings;
require './backup-config-lib.pl';
+our (%in, %text);
&ReadParse();
+
+my $backup;
if ($in{'new'}) {
&ui_print_header(undef, $text{'edit_title1'}, "");
$backup = { 'emode' => 0,
print &ui_hidden("new", $in{'new'});
print &ui_hidden("id", $in{'id'});
-@tds = ( "width=30%" );
+my @tds = ( "width=30%" );
print &ui_hidden_table_start($text{'edit_header'}, "width=100%", 2,
"main", 1, \@tds);
# Show modules to backup
-@mods = &list_backup_modules();
-@dmods = split(/\s+/, $backup->{'mods'});
+my @mods = &list_backup_modules();
+my @dmods = split(/\s+/, $backup->{'mods'});
print &ui_table_row($text{'edit_mods'},
&ui_select("mods", \@dmods,
[ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
[ 1, $text{'edit_emode1'} ] ]));
# Show schedule
+my $job;
if ($backup) {
$job = &find_cron_job($backup);
}
#!/usr/local/bin/perl
# Show all scheduled backups, and a form for doing an immediate one
+use strict;
+use warnings;
require './backup-config-lib.pl';
+our (%text, %in, %config);
&ReadParse();
+
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
-@mods = &list_backup_modules();
+my @mods = &list_backup_modules();
if (!@mods) {
&ui_print_endpage($text{'index_emods'});
}
-%mods = map { $_->{'dir'}, $_ } @mods;
+my %mods = map { $_->{'dir'}, $_ } @mods;
# Show tabs
-@tabs = ( [ "backup", $text{'index_tabbackup'}, "index.cgi?mode=backup" ],
- [ "sched", $text{'index_tabsched'}, "index.cgi?mode=sched" ],
- [ "restore", $text{'index_tabrestore'}, "index.cgi?mode=restore" ],
- );
+my @tabs = ( [ "backup", $text{'index_tabbackup'}, "index.cgi?mode=backup" ],
+ [ "sched", $text{'index_tabsched'}, "index.cgi?mode=sched" ],
+ [ "restore", $text{'index_tabrestore'}, "index.cgi?mode=restore" ],
+ );
print &ui_tabs_start(\@tabs, "tab", $in{'mode'} || "backup", 1);
print &ui_tabs_start_tab("tab", "sched");
-@backups = &list_backups();
+my @backups = &list_backups();
+my $using_strftime = 0;
if (@backups) {
# Show all scheduled backups
print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><br>\n";
print &ui_columns_start([ $text{'index_dest'},
$text{'index_mods'},
$text{'index_sched'} ], 100);
- foreach $b (@backups) {
- local @m = map { $mods{$_}->{'desc'} }
- split(/\s+/, $b->{'mods'});
+ foreach my $b (@backups) {
+ my @m = map { $mods{$_}->{'desc'} }
+ split(/\s+/, $b->{'mods'});
print &ui_columns_row(
[ "<a href='edit.cgi?id=$b->{'id'}'>".
&nice_dest($b->{'dest'})."</a>",
print &ui_form_start("backup.cgi/backup.tgz", "post");
print &ui_table_start($text{'index_header'}, undef, 2);
-@dmods = split(/\s+/, $config{'mods'});
+my @dmods = split(/\s+/, $config{'mods'});
print &ui_table_row($text{'edit_mods'},
&ui_select("mods", \@dmods,
[ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
print &ui_form_start("restore.cgi", "form-data");
print &ui_table_start($text{'index_header2'}, undef, 2);
-@dmods = split(/\s+/, $config{'mods'});
print &ui_table_row($text{'edit_mods2'},
&ui_select("mods", \@dmods,
[ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
# log_parser.pl
# Functions for parsing this module's logs
+use strict;
+use warnings;
do 'backup-config-lib.pl';
+our (%text);
# parse_webmin_log(user, script, action, type, object, ¶ms)
# Converts logged information from this module into human-readable form
#!/usr/local/bin/perl
# Do an immediate restore
+use strict;
+use warnings;
require './backup-config-lib.pl';
+our (%in, %text, %config, $module_config_file);
&ReadParseMime();
# Validate inputs
&error_setup($text{'restore_err'});
-$src = &parse_backup_destination("src", \%in);
-@mods = split(/\0/, $in{'mods'});
+my $src = &parse_backup_destination("src", \%in);
+my @mods = split(/\0/, $in{'mods'});
@mods || &error($text{'restore_emods'});
# Do it ..
-($mode, $user, $pass, $server, $path, $port) = &parse_backup_url($src);
+my ($mode, $user, $pass, $server, $path, $port) = &parse_backup_url($src);
if ($mode == 3) {
# Create temp file for uploaded file
- $temp = &transname();
+ my $temp = &transname();
open(TEMP, ">$temp");
print TEMP $in{$path};
close(TEMP);
&ui_print_header(undef, $text{'restore_title'}, "");
print &text($in{'test'} ? 'restore_testing' : 'restore_doing',
&nice_dest($src)),"<p>\n";
-$err = &execute_restore(\@mods, $src, \@files, $in{'apply'}, $in{'test'});
-&unlink_file($temp) if ($mode == 3);
+my @files;
+my $err = &execute_restore(\@mods, $src, \@files, $in{'apply'}, $in{'test'});
+&unlink_file($src) if ($mode == 3);
if ($err) {
print &text('restore_failed', $err),"<p>\n";
}
#!/usr/local/bin/perl
# Create, update or delete a scheduled backup
+use strict;
+use warnings;
require './backup-config-lib.pl';
+our (%in, %text, $cron_cmd, $module_name);
&ReadParse();
# Find the backup job
+my ($job, $backup);
if (!$in{'new'}) {
$backup = &get_backup($in{'id'});
$job = &find_cron_job($backup);
else {
# Validate inputs
&error_setup($text{'save_err'});
- @mods = split(/\0/, $in{'mods'});
+ my @mods = split(/\0/, $in{'mods'});
$backup->{'mods'} = join(" ", @mods);
$backup->{'dest'} = &parse_backup_destination("dest", \%in);
&cron::parse_times_input($backup, \%in);
&ui_print_unbuffered_header(undef, $text{'run_title'}, "");
# Run the pre-backup command, if any
+ my $err;
if ($backup->{'pre'} =~ /\S/) {
- $preout = &backquote_command(
+ my $preout = &backquote_command(
"($backup->{'pre'}) 2>&1 </dev/null");
print &text('email_pre',
"<tt>".&html_escape($backup->{'pre'})."</tt>")."<br>\n".
}
}
- @mods = split(/\s+/, $backup->{'mods'});
- $nice = &nice_dest($backup->{'dest'}, 1);
+ my @mods = split(/\s+/, $backup->{'mods'});
+ my $nice = &nice_dest($backup->{'dest'}, 1);
if (!$err) {
print &text('run_doing', scalar(@mods),
"<tt>$nice</tt>"),"<br>\n";
+ my $size;
$err = &execute_backup(
\@mods, $backup->{'dest'}, \$size, undef,
$backup->{'configfile'}, $backup->{'nofiles'},
# Run the post-backup command, if any
if (!$err && $backup->{'post'} =~ /\S/) {
- $postout = &backquote_command(
+ my $postout = &backquote_command(
"($backup->{'post'}) 2>&1 </dev/null");
print &text('email_post',
"<tt>".&html_escape($backup->{'post'})."</tt>")."<br>\n".
&webmin_log("run", "backup", $backup->{'dest'}, $backup);
&ui_print_footer("edit.cgi?id=$in{'id'}", $text{'edit_return'},
"index.cgi?mode=sched", $text{'index_return'});
- exit;
}
else {
&redirect("index.cgi?mode=sched");
# uninstall.pl
# Called when webmin is uninstalled
+use strict;
+use warnings;
require 'backup-config-lib.pl';
sub module_uninstall
{
-foreach $backup (&list_backups()) {
- $job = &find_cron_job($backup);
+foreach my $backup (&list_backups()) {
+ my $job = &find_cron_job($backup);
if ($job) {
&cron::delete_cron_job($job);
}