+ #
+ # If the restore failed, clean up
+ #
+ if ( !$stat{xferOK} ) {
+ #
+ # wait a short while and see if the system is still alive
+ #
+ $stat{hostError} ||= $tarCreateErr if ( $tarCreateErr ne "" );
+ $stat{hostError} = $stat{lastOutputLine} if ( $stat{hostError} eq "" );
+ sleep(2);
+ if ( $bpc->CheckHostAlive($hostIP) < 0 ) {
+ $stat{hostAbort} = 1;
+ }
+ if ( $stat{hostAbort} && $stat{hostError} eq "" ) {
+ $stat{hostError} = "lost network connection during restore";
+ }
+ $RestoreLOG->write(\"restore failed: $stat{hostError}\n")
+ if ( defined($RestoreLOG) );
+ }
+
+ $RestoreLOG->close() if ( defined($RestoreLOG) );
+
+ #
+ # Add the new restore information to the restore file
+ #
+ @Restores = $bpc->RestoreInfoRead($client);
+ my $i = @Restores;
+ $Restores[$i]{num} = $lastNum;
+ $Restores[$i]{startTime} = $startTime;
+ $Restores[$i]{endTime} = $endTime;
+ $Restores[$i]{result} = $stat{xferOK} ? "ok" : "failed";
+ $Restores[$i]{errorMsg} = $stat{hostError};
+ $Restores[$i]{nFiles} = $tarCreateFileCnt;
+ $Restores[$i]{size} = $tarCreateByteCnt;
+ $Restores[$i]{tarCreateErrs} = $tarCreateErrCnt;
+ $Restores[$i]{xferErrs} = $stat{xferErrCnt} || 0;
+
+ while ( @Restores > $Conf{RestoreInfoKeepCnt} ) {
+ my $num = $Restores[0]{num};
+ unlink("$Dir/RestoreLOG.$num.z");
+ unlink("$Dir/RestoreLOG.$num");
+ unlink("$Dir/RestoreInfo.$num");
+ shift(@Restores);
+ }
+ $bpc->RestoreInfoWrite($client, @Restores);
+
+ if ( !$stat{xferOK} ) {
+ print(LOG $bpc->timeStamp, "restore failed ($stat{hostError})\n");
+ print("restore failed: $stat{hostError}\n");
+ return 1;
+ } else {
+ $stat{xferErrCnt} ||= 0;
+ print(LOG $bpc->timeStamp, "restore $lastNum complete"
+ . " ($tarCreateFileCnt files, $tarCreateByteCnt bytes,"
+ . " $tarCreateDirCnt dirs, $stat{xferErrCnt} xferErrs)\n");
+ print("restore complete\n");
+ return;
+ }