From: cw <we...@fi...> - 2004-09-29 13:45:30
|
Jamie Cameron wrote: > At the moment, there isn't any way of automatically restoring a backup. > However, this is relatively easy to add, so in the next Virtualmin I > will create a restore.pl script that can be called from a Cron job or > the command line to restore a backup file created by Virtualmin. That is exactly what I have been doing today. I think I have the script working but it tells me "you are not allowed to run backups". I thought the line "$no_acl_check++;" sorted that in the backup.pl script but it doesn't do the same for my restore2.pl? I haven't had a chance to look into that bit any more yet as we are having carpet relayed in the office today and the servers are isolated from all the computers that are left running. The scripts I put together are: /etc/webmin/virtual-server/restore.pl --Start copy/paste #!/usr/bin/perl open(CONF, "/etc/webmin/miniserv.conf"); while(<CONF>) { $root = $1 if (/^root=(.*)/); } close(CONF); $ENV{'WEBMIN_CONFIG'} = "/etc/webmin"; $ENV{'WEBMIN_VAR'} = "/var/webmin"; chdir("$root/virtual-server"); exec("$root/virtual-server/restore2.pl", @ARGV); --End copy/paste /usr/src/webmin-1.160/virtual-server/restore2.pl --Start copy/paste #!/usr/bin/perl # Do a scheduled virtual server restore $no_acl_check++; require './virtual-server-lib.pl'; $src = '/home/delladmin/backup/current.tar.gz' &master_admin() || &error($text{'restore_ecannot'}); &ReadParse(); ($mode) = &parse_backup_url($src); $mode > 0 || -r $src || -d $src || &error($text{'restore_esrc'}); $cont = &backup_contents($src); @dfeats = @{$cont->{$d}}; %dfeats = map { $_, 1 } @dfeats; $any++; # Parse option inputs foreach $f(@dfeats) { local $ofunc = "parse_restore_$f"; if (defined(&$ofunc)) { $options{$f} = &$ofunc(\%in); } } # See what is in the tar file or directory ref($cont) || &error(&text('restore_efile', $cont)); (keys %$cont) || &error($text{'restore_enone'}); ##Do all domains in the tar file foreach $d (sort { $a cmp $b } keys %$cont) { local $dinfo = &get_domain_by("dom", $d); if ($dinfo) { push(@doms, $dinfo); } else { push(@doms, { 'dom' => $d, 'missing' => 1 }); } } @doms || &error($text{'restore_edoms'}); #&ui_print_unbuffered_header(undef, $text{'restore_title'}, ""); # Actually execute the restore print "<p>",&text('restore_doing', scalar(@doms), "<tt>$src</tt>"),"<p>\n"; $ok = &restore_domains($src, \@doms, \@dfeats, \%options); &run_post_actions(); if ($ok) { print &text('restore_done'),"<p>\n"; } else { print &text('restore_failed'),"<p>\n"; } &webmin_log("restore", $src, undef, { 'doms' => [ map { $_->{'dom'} } @doms ] }); #&ui_print_footer("", $text{'index_return'}); --End copy/paste Regards, Colin. |