- fixed configure.pl and makeDist.
[BackupPC.git] / bin / BackupPC_restore
1 #!/bin/perl
2 #============================================================= -*-perl-*-
3 #
4 # BackupPC_restore: Restore files to a client.
5 #
6 # DESCRIPTION
7 #
8 #   Usage: BackupPC_restore <hostIP> <client> <reqFileName>
9 #
10 # AUTHOR
11 #   Craig Barratt  <cbarratt@users.sourceforge.net>
12 #
13 # COPYRIGHT
14 #   Copyright (C) 2001-2003  Craig Barratt
15 #
16 #   This program is free software; you can redistribute it and/or modify
17 #   it under the terms of the GNU General Public License as published by
18 #   the Free Software Foundation; either version 2 of the License, or
19 #   (at your option) any later version.
20 #
21 #   This program is distributed in the hope that it will be useful,
22 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
23 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 #   GNU General Public License for more details.
25 #
26 #   You should have received a copy of the GNU General Public License
27 #   along with this program; if not, write to the Free Software
28 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29 #
30 #========================================================================
31 #
32 # Version 3.0.0alpha, released 23 Jan 2006.
33 #
34 # See http://backuppc.sourceforge.net.
35 #
36 #========================================================================
37
38 use strict;
39 no  utf8;
40 use lib "/usr/local/BackupPC/lib";
41 use BackupPC::Lib;
42 use BackupPC::FileZIO;
43 use BackupPC::Xfer::Smb;
44 use BackupPC::Xfer::Tar;
45 use BackupPC::Xfer::Rsync;
46 use BackupPC::Xfer::BackupPCd;
47 use Socket;
48
49 use File::Path;
50 use Getopt::Std;
51
52 use vars qw( %RestoreReq );
53
54 ###########################################################################
55 # Initialize
56 ###########################################################################
57
58 die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
59 my $TopDir = $bpc->TopDir();
60 my $BinDir = $bpc->BinDir();
61 my %Conf   = $bpc->Conf();
62 my $NeedPostCmd;
63
64 my($hostIP, $host, $client, $reqFileName, %stat);
65
66 $bpc->ChildInit();
67
68 if ( @ARGV != 3 ) {
69     print("usage: $0 <hostIP> <client> <reqFileName>\n");
70     exit(1);
71 }
72 $hostIP = $1 if ( $ARGV[0] =~ /(.+)/ );
73 $client = $1 if ( $ARGV[1] =~ /(.+)/ );
74 if ( $ARGV[2] !~ /^([\w.]+)$/ ) {
75     print("$0: bad reqFileName (arg #3): $ARGV[2]\n");
76     exit(1);
77 }
78 $reqFileName = $1;
79
80 my $startTime = time();
81
82 my $Hosts = $bpc->HostInfoRead($client);
83
84 my $Dir     = "$TopDir/pc/$client";
85 my @xferPid = ();
86 my $tarPid  = -1;
87
88 #
89 # Catch various signals
90 #
91 $SIG{INT}  = \&catch_signal;
92 $SIG{ALRM} = \&catch_signal;
93 $SIG{TERM} = \&catch_signal;
94 $SIG{PIPE} = \&catch_signal;
95 $SIG{STOP} = \&catch_signal;
96 $SIG{TSTP} = \&catch_signal;
97 $SIG{TTIN} = \&catch_signal;
98 my $Pid = $$;
99
100 mkpath($Dir, 0, 0777) if ( !-d $Dir );
101 if ( !-f "$Dir/LOCK" ) {
102     open(LOCK, ">", "$Dir/LOCK") && close(LOCK);
103 }
104 open(LOG, ">>", "$Dir/LOG");
105 select(LOG); $| = 1; select(STDOUT);
106
107
108 #
109 # Read the request file
110 #
111 if ( !(my $ret = do "$Dir/$reqFileName") ) {
112     my $err;
113     if ( $@ ) {
114         $err = "couldn't parse $Dir/$reqFileName: $@";
115     } elsif ( !defined($ret) ) {
116         $err = "couldn't do $Dir/$reqFileName: $!";
117     } else {
118         $err = "couldn't run $Dir/$reqFileName";
119     }
120     $stat{hostError} = $err;
121     exit(RestoreCleanup($client));
122 }
123
124 #
125 # Re-read config file, so we can include the PC-specific config
126 #
127 if ( defined(my $error = $bpc->ConfigRead($client)) ) {
128     $stat{hostError} = "Can't read PC's config file: $error";
129     exit(RestoreCleanup($client));
130 }
131 %Conf = $bpc->Conf();
132
133 #
134 # Make sure we eventually timeout if there is no activity from
135 # the data transport program.
136 #
137 alarm($Conf{ClientTimeout});
138
139 #
140 # See if the host name is aliased
141 #
142 if ( $Conf{ClientNameAlias} ne "" ) {
143     $host = $Conf{ClientNameAlias};
144 } else {
145     $host = $client;
146 }
147
148 #
149 # Find its IP address
150 #
151 if ( $hostIP !~ /\d+\.\d+\.\d+\.\d+/ ) {
152     if ( !defined(gethostbyname($host)) ) {
153         #
154         # Ok, NS doesn't know about it.  Maybe it is a NetBios name
155         # instead.
156         #
157         if ( !defined($hostIP = $bpc->NetBiosHostIPFind($host)) ) {
158             $stat{hostError} = "Can't find host $host";
159             exit(RestoreCleanup($client));
160         }
161     } else {
162         $hostIP = $host;
163     }
164 }
165
166 #
167 # Check if $host is alive
168 #
169 my $delay = $bpc->CheckHostAlive($hostIP);
170 if ( $delay < 0 ) {
171     $stat{hostError} = "no ping response from $host ($hostIP)";
172     exit(RestoreCleanup($client));
173 } elsif ( $delay > $Conf{PingMaxMsec} ) {
174     $stat{hostError} = sprintf("ping too slow: %.4gmsec (max is %gmsec)\n",
175                     $delay, $Conf{PingMaxMsec});
176     exit(RestoreCleanup($client));
177 }
178
179 #
180 # Make sure it is really the machine we expect
181 #
182 if ( (my $errMsg = CorrectHostCheck($hostIP, $host)) ) {
183     $stat{hostError} = $errMsg;
184     exit(RestoreCleanup($client));
185 }
186
187 #
188 # Setup file extension for compression and open RestoreLOG output file
189 #
190 if ( $Conf{CompressLevel} && !BackupPC::FileZIO->compOk ) {
191     $stat{hostError} = "Compress:Zlib not found";
192     exit(RestoreCleanup($client));
193 }
194 my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : "";
195 my $RestoreLOG = BackupPC::FileZIO->open("$Dir/RestoreLOG$fileExt", 1,
196                                      $Conf{CompressLevel});
197 my $tarCreateFileCnt = 0;
198 my $tarCreateByteCnt = 0;
199 my $tarCreateErrCnt  = 1;       # assume not ok until we learn otherwise
200 my $tarCreateErr;
201 my($logMsg, $xfer);
202
203 $stat{xferOK} = $stat{hostAbort} = undef;
204 $stat{hostError} = $stat{lastOutputLine} = undef;
205 local(*RH, *WH);
206
207 #
208 # Run an optional pre-restore command
209 #
210 UserCommandRun("RestorePreUserCmd");
211 $NeedPostCmd = 1;
212
213 if ( $Conf{XferMethod} eq "tar" ) {
214     #
215     # Use tar (eg: tar/ssh) as the transport program.
216     #
217     $xfer = BackupPC::Xfer::Tar->new($bpc);
218 } elsif ( $Conf{XferMethod} eq "rsync" || $Conf{XferMethod} eq "rsyncd" ) {
219     #
220     # Use rsync as the transport program.
221     #
222     if ( !defined($xfer = BackupPC::Xfer::Rsync->new($bpc)) ) {
223         my $errStr = BackupPC::Xfer::Rsync->errStr;
224         UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
225         $stat{hostError} = $errStr;
226         exit(RestoreCleanup($client));
227     }
228 } elsif ( $Conf{XferMethod} eq "backuppcd" ) {
229     #
230     # Use backuppcd as the transport program.
231     #
232     if ( !defined($xfer = BackupPC::Xfer::BackupPCd->new($bpc)) ) {
233         my $errStr = BackupPC::Xfer::BackupPCd->errStr;
234         UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
235         $stat{hostError} = $errStr;
236         exit(RestoreCleanup($client));
237     }
238 } else {
239     #
240     # Default is to use smbclient (smb) as the transport program.
241     #
242     $xfer = BackupPC::Xfer::Smb->new($bpc);
243 }
244 my $useTar = $xfer->useTar;
245
246 if ( $useTar ) {
247     #
248     # Create a socketpair to connect BackupPC_tarCreate to the transport
249     # program (smbclient, tar, etc).
250     # WH is the write handle for writing, provided to BackupPC_tarCreate
251     # and RH is the other end of the pipe for reading provided to the
252     # transport program.
253     #
254     if ( socketpair(RH, WH, AF_UNIX, SOCK_STREAM, PF_UNSPEC) ) {
255         shutdown(RH, 1);    # no writing to this socket
256         shutdown(WH, 0);    # no reading from this socket
257         setsockopt(RH, SOL_SOCKET, SO_RCVBUF, 8 * 65536);
258         setsockopt(WH, SOL_SOCKET, SO_SNDBUF, 8 * 65536);
259     } else {
260         #
261         # Default to pipe() if socketpair() doesn't work.
262         #
263         pipe(RH, WH);
264     }
265 }
266
267 #
268 # Run the transport program, which reads from RH and extracts the data.
269 #
270 my @Backups = $bpc->BackupInfoRead($RestoreReq{hostSrc});
271 my $xferArgs = {
272     client       => $client,
273     host         => $host,
274     hostIP       => $hostIP,
275     type         => "restore",
276     shareName    => $RestoreReq{shareDest},
277     pipeRH       => *RH,
278     pipeWH       => *WH,
279     XferLOG      => $RestoreLOG,
280     XferMethod   => $Conf{XferMethod},
281     logLevel     => $Conf{XferLogLevel},
282     bkupSrcHost  => $RestoreReq{hostSrc},
283     bkupSrcShare => $RestoreReq{shareSrc},
284     bkupSrcNum   => $RestoreReq{num},
285     backups      => \@Backups,
286     pathHdrSrc   => $RestoreReq{pathHdrSrc},
287     pathHdrDest  => $RestoreReq{pathHdrDest},
288     fileList     => $RestoreReq{fileList},
289     pidHandler   => \&pidHandler,
290 };
291
292 $xfer->args($xferArgs);
293
294 if ( !defined($logMsg = $xfer->start()) ) {
295     UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
296     $stat{hostError} = "xfer start failed: ", $xfer->errStr;
297     exit(RestoreCleanup($client));
298 }
299
300 if ( $useTar ) {
301     #
302     # Now do the restore by running BackupPC_tarCreate
303     #
304     # The parent must close the read handle since the transport program
305     # is using it.
306     #
307     close(RH);
308
309     #
310     # fork a child for BackupPC_tarCreate.  TAR is a file handle
311     # on which we (the parent) read the stderr from BackupPC_tarCreate.
312     #
313     my @tarPathOpts;
314     if ( defined($RestoreReq{pathHdrDest})
315                 && $RestoreReq{pathHdrDest} ne $RestoreReq{pathHdrSrc} ) {
316         @tarPathOpts = ("-r", $RestoreReq{pathHdrSrc},
317                         "-p", $RestoreReq{pathHdrDest}
318                 );
319     }
320     my @tarArgs = (
321              "-h", $RestoreReq{hostSrc},
322              "-n", $RestoreReq{num},
323              "-s", $RestoreReq{shareSrc},
324              "-t",
325              @tarPathOpts,
326              @{$RestoreReq{fileList}},
327     );
328     my $logMsg = "Running: "
329                . $bpc->execCmd2ShellCmd("$BinDir/BackupPC_tarCreate", @tarArgs)
330                . "\n";
331     $RestoreLOG->write(\$logMsg);
332     if ( !defined($tarPid = open(TAR, "-|")) ) {
333         close(WH);
334         # FIX: need to cleanup xfer
335         UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
336         $stat{hostError} = "Can't fork to run tar";
337         exit(RestoreCleanup($client));
338     }
339     binmode(TAR);
340     if ( !$tarPid ) {
341         #
342         # This is the tarCreate child.  Clone STDERR to STDOUT,
343         # STDOUT to WH, and then exec BackupPC_tarCreate.
344         #
345         setpgrp 0,0;
346         close(STDERR);
347         open(STDERR, ">&STDOUT");
348         close(STDOUT);
349         open(STDOUT, ">&WH");
350         alarm(0);
351         exec("$BinDir/BackupPC_tarCreate", @tarArgs);
352         print(LOG $bpc->timeStamp, "can't exec $BinDir/BackupPC_tarCreate\n");
353         # FIX: need to cleanup xfer
354         exit(0);
355     }
356     #
357     # The parent must close the write handle since BackupPC_tarCreate
358     # is using it.
359     #
360     close(WH);
361
362     @xferPid = $xfer->xferPid;
363
364     print(LOG $bpc->timeStamp, $logMsg, "\n");
365     print("started_restore\n");
366
367     pidHandler(@xferPid);
368
369     #
370     # Parse the output of the transfer program and BackupPC_tarCreate
371     # while they run.  Since we are reading from two or more children
372     # we use a select.
373     #
374     my($FDread, $tarOut, $mesg);
375     vec($FDread, fileno(TAR), 1) = 1;
376     $xfer->setSelectMask(\$FDread);
377
378     SCAN: while ( 1 ) {
379         my $ein = $FDread;
380         last if ( $FDread =~ /^\0*$/ );
381         alarm($Conf{ClientTimeout});
382         select(my $rout = $FDread, undef, $ein, undef);
383         if ( vec($rout, fileno(TAR), 1) ) {
384             if ( sysread(TAR, $mesg, 8192) <= 0 ) {
385                 vec($FDread, fileno(TAR), 1) = 0;
386                 if ( !close(TAR) ) {
387                     $tarCreateErrCnt  = 1;
388                     $tarCreateErr = "BackupPC_tarCreate failed";
389                 }
390             } else {
391                 $tarOut .= $mesg;
392             }
393         }
394         while ( $tarOut =~ /(.*?)[\n\r]+(.*)/s ) {
395             $_ = $1;
396             $tarOut = $2;
397             $RestoreLOG->write(\"tarCreate: $_\n");
398             if ( /^Done: (\d+) files, (\d+) bytes, (\d+) dirs, (\d+) specials, (\d+) errors/ ) {
399                 $tarCreateFileCnt = $1;
400                 $tarCreateByteCnt = $2;
401                 $tarCreateErrCnt  = $5;
402             }
403         }
404         last if ( !$xfer->readOutput(\$FDread, $rout) );
405         while ( my $str = $xfer->logMsgGet ) {
406             print(LOG $bpc->timeStamp, "xfer: $str\n");
407         }
408         if ( $xfer->getStats->{fileCnt} == 1 ) {
409             #
410             # Make sure it is still the machine we expect.  We do this while
411             # the transfer is running to avoid a potential race condition if
412             # the ip address was reassigned by dhcp just before we started
413             # the transfer.
414             #
415             if ( my $errMsg = CorrectHostCheck($hostIP, $host) ) {
416                 $stat{hostError} = $errMsg;
417                 last SCAN;
418             }
419         }
420     }
421 } else {
422     #
423     # otherwise the xfer module does everything for us
424     #
425     print(LOG $bpc->timeStamp, "Starting restore\n");
426     print("started_restore\n");
427     ($tarCreateFileCnt, $tarCreateByteCnt,
428         $tarCreateErrCnt, $tarCreateErr) = $xfer->run();
429 }
430 alarm(0);
431
432 #
433 # Merge the xfer status (need to accumulate counts)
434 #
435 my $newStat = $xfer->getStats;
436 foreach my $k ( (keys(%stat), keys(%$newStat)) ) {
437     next if ( !defined($newStat->{$k}) );
438     if ( $k =~ /Cnt$/ ) {
439         $stat{$k} += $newStat->{$k};
440         delete($newStat->{$k});
441         next;
442     }
443     if ( !defined($stat{$k}) ) {
444         $stat{$k} = $newStat->{$k};
445         delete($newStat->{$k});
446         next;
447     }
448 }
449
450 exit(RestoreCleanup($client));
451
452 ###########################################################################
453 # Subroutines
454 ###########################################################################
455
456 sub CorrectHostCheck
457 {
458     my($hostIP, $host) = @_;
459     return if ( $hostIP eq $host && !$Conf{FixedIPNetBiosNameCheck}
460                 || $Conf{NmbLookupCmd} eq "" );
461     my($netBiosHost, $netBiosUser) = $bpc->NetBiosInfoGet($hostIP);
462     return "host $host has mismatching netbios name $netBiosHost"
463             if ( $netBiosHost ne $host );
464     return;
465 }
466
467 sub catch_signal
468 {
469     my $signame = shift;
470
471     #
472     # Children quit quietly on ALRM
473     #
474     exit(1) if ( $Pid != $$ && $signame eq "ALRM" );
475
476     #
477     # Ignore signals in children
478     #
479     return if ( $Pid != $$ );
480
481     #
482     # Note: needs to be tested for each kind of XferMethod
483     #
484     print(LOG $bpc->timeStamp, "cleaning up after signal $signame\n");
485     $SIG{$signame} = 'IGNORE';
486     $RestoreLOG->write(\"exiting after signal $signame\n");
487     $stat{xferOK} = 0;
488     if ( $signame eq "INT" ) {
489         $stat{hostError} = "aborted by user (signal=$signame)";
490     } else {
491         $stat{hostError} = "aborted by signal=$signame";
492     }
493     exit(RestoreCleanup($client));
494 }
495
496 #
497 # Cleanup and update the restore status
498 #
499 sub RestoreCleanup
500 {
501     my($client) = @_;
502
503     $stat{xferOK} = 0 if ( $stat{hostError} || $stat{hostAbort}
504                         || $tarCreateErr );
505
506     if ( !$stat{xferOK} ) {
507         #
508         # kill off the tranfer program, first nicely then forcefully
509         #
510         if ( @xferPid ) {
511             kill($bpc->sigName2num("INT"), @xferPid);
512             sleep(1);
513             kill($bpc->sigName2num("KILL"), @xferPid);
514         }
515         #
516         # kill off the tar process, first nicely then forcefully
517         #
518         if ( $tarPid > 0 ) {
519             kill($bpc->sigName2num("INT"), $tarPid);
520             sleep(1);
521             kill($bpc->sigName2num("KILL"), $tarPid);
522         }
523     }
524
525     my $lastNum  = -1;
526     my @Restores;
527
528     #
529     # Do one last check to make sure it is still the machine we expect.
530     #
531     if ( $stat{xferOK} && (my $errMsg = CorrectHostCheck($hostIP, $host)) ) {
532         $stat{hostError} = $errMsg;
533         $stat{xferOK} = 0;
534     }
535     @Restores = $bpc->RestoreInfoRead($client);
536     for ( my $i = 0 ; $i < @Restores ; $i++ ) {
537         $lastNum = $Restores[$i]{num} if ( $lastNum < $Restores[$i]{num} );
538     }
539     $lastNum++;
540
541     #
542     # Run an optional post-restore command
543     #
544     UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
545
546     rename("$Dir/RestoreLOG$fileExt", "$Dir/RestoreLOG.$lastNum$fileExt");
547     rename("$Dir/$reqFileName", "$Dir/RestoreInfo.$lastNum");
548     my $endTime = time();
549
550     #
551     # If the restore failed, clean up
552     #
553     if ( !$stat{xferOK} ) {
554         #
555         # wait a short while and see if the system is still alive
556         #
557         $stat{hostError} ||= $tarCreateErr if ( $tarCreateErr ne "" );
558         $stat{hostError} = $stat{lastOutputLine} if ( $stat{hostError} eq "" );
559         sleep(2);
560         if ( $bpc->CheckHostAlive($hostIP) < 0 ) {
561             $stat{hostAbort} = 1;
562         }
563         if ( $stat{hostAbort} && $stat{hostError} eq "" ) {
564             $stat{hostError} = "lost network connection during restore";
565         }
566         $RestoreLOG->write(\"Restore failed: $stat{hostError}\n")
567                                             if ( defined($RestoreLOG) );
568     }
569
570     $RestoreLOG->close() if ( defined($RestoreLOG) );
571
572     #
573     # Add the new restore information to the restore file
574     #
575     @Restores = $bpc->RestoreInfoRead($client);
576     my $i = @Restores;
577     $Restores[$i]{num}           = $lastNum;
578     $Restores[$i]{startTime}     = $startTime;
579     $Restores[$i]{endTime}       = $endTime;
580     $Restores[$i]{result}        = $stat{xferOK} ? "ok" : "failed";
581     $Restores[$i]{errorMsg}      = $stat{hostError};
582     $Restores[$i]{nFiles}        = $tarCreateFileCnt;
583     $Restores[$i]{size}          = $tarCreateByteCnt;
584     $Restores[$i]{tarCreateErrs} = $tarCreateErrCnt;
585     $Restores[$i]{xferErrs}      = $stat{xferErrCnt} || 0;
586
587     while ( @Restores > $Conf{RestoreInfoKeepCnt} ) {
588         my $num = $Restores[0]{num};
589         unlink("$Dir/RestoreLOG.$num.z");
590         unlink("$Dir/RestoreLOG.$num");
591         unlink("$Dir/RestoreInfo.$num");
592         shift(@Restores);
593     }
594     $bpc->RestoreInfoWrite($client, @Restores);
595
596     if ( !$stat{xferOK} ) {
597         print(LOG $bpc->timeStamp, "Restore failed ($stat{hostError})\n");
598         print("restore failed: $stat{hostError}\n");
599         return 1;
600     } else {
601         print("restore complete\n");
602         return;
603     }
604 }
605
606 #
607 # The Xfer method might tell us from time to time about processes
608 # it forks.  We tell BackupPC about this (for status displays) and
609 # keep track of the pids in case we cancel the backup
610 #
611 sub pidHandler
612 {
613     @xferPid = @_;
614     @xferPid = grep(/./, @xferPid);
615     return if ( !@xferPid && $tarPid < 0 );
616     my @pids = @xferPid;
617     push(@pids, $tarPid) if ( $tarPid > 0 );
618     my $str = join(",", @pids);
619     $RestoreLOG->write(\"Xfer PIDs are now $str\n") if ( defined($RestoreLOG) );
620     print("xferPids $str\n");
621 }
622
623 #
624 # Run an optional pre- or post-dump command
625 #
626 sub UserCommandRun
627 {
628     my($cmdType) = @_;
629
630     return if ( !defined($Conf{$cmdType}) );
631     my $vars = {
632         xfer         => $xfer,
633         client       => $client,
634         host         => $host,
635         hostIP       => $hostIP,
636         share        => $RestoreReq{shareDest},
637         XferMethod   => $Conf{XferMethod},
638         sshPath      => $Conf{SshPath},
639         LOG          => *LOG,
640         user         => $Hosts->{$client}{user},
641         moreUsers    => $Hosts->{$client}{moreUsers},
642         XferLOG      => $RestoreLOG,
643         stat         => \%stat,
644         xferOK       => $stat{xferOK} || 0,
645         hostError    => $stat{hostError},
646         type         => "restore",
647         bkupSrcHost  => $RestoreReq{hostSrc},
648         bkupSrcShare => $RestoreReq{shareSrc},
649         bkupSrcNum   => $RestoreReq{num},
650         backups      => \@Backups,
651         pathHdrSrc   => $RestoreReq{pathHdrSrc},
652         pathHdrDest  => $RestoreReq{pathHdrDest},
653         fileList     => $RestoreReq{fileList},
654         cmdType      => $cmdType,
655     };
656     my $cmd = $bpc->cmdVarSubstitute($Conf{$cmdType}, $vars);
657     $RestoreLOG->write(\"Executing $cmdType: @$cmd\n");
658     #
659     # Run the user's command, dumping the stdout/stderr into the
660     # Xfer log file.  Also supply the optional $vars and %Conf in
661     # case the command is really perl code instead of a shell
662     # command.
663     #
664     $bpc->cmdSystemOrEval($cmd,
665             sub {
666                 $RestoreLOG->write(\$_[0]);
667             },
668             $vars, \%Conf);
669 }