- setpgrp 0,0;
- close(STDERR);
- open(STDERR, ">&STDOUT");
- close(STDOUT);
- open(STDOUT, ">&WH");
- exec("$BinDir/BackupPC_tarCreate", @tarArgs);
- print(LOG $bpc->timeStamp, "can't exec $BinDir/BackupPC_tarCreate\n");
- # FIX: need to cleanup xfer
- exit(0);
-}
-#
-# The parent must close the write handle since BackupPC_tarCreate
-# is using it.
-#
-close(WH);
+ my @tarPathOpts;
+ if ( defined($RestoreReq{pathHdrDest})
+ && $RestoreReq{pathHdrDest} ne $RestoreReq{pathHdrSrc} ) {
+ @tarPathOpts = ("-r", $RestoreReq{pathHdrSrc},
+ "-p", $RestoreReq{pathHdrDest}
+ );
+ }
+ my @tarArgs = (
+ "-h", $RestoreReq{hostSrc},
+ "-n", $RestoreReq{num},
+ "-s", $RestoreReq{shareSrc},
+ "-t",
+ @tarPathOpts,
+ @{$RestoreReq{fileList}},
+ );
+ my $runMsg = "Running: "
+ . $bpc->execCmd2ShellCmd("$BinDir/BackupPC_tarCreate", @tarArgs)
+ . "\n";
+ $RestoreLOG->write(\$runMsg);
+ if ( !defined($tarPid = open(TAR, "-|")) ) {
+ close(WH);
+ # FIX: need to cleanup xfer
+ UserCommandRun("RestorePostUserCmd") if ( $NeedPostCmd );
+ $stat{hostError} = "Can't fork to run tar";
+ exit(RestoreCleanup($client));
+ }
+ binmode(TAR);
+ if ( !$tarPid ) {
+ #
+ # This is the tarCreate child. Clone STDERR to STDOUT,
+ # STDOUT to WH, and then exec BackupPC_tarCreate.
+ #
+ setpgrp 0,0;
+ close(STDERR);
+ open(STDERR, ">&STDOUT");
+ close(STDOUT);
+ open(STDOUT, ">&WH");
+ alarm(0);
+ exec("$BinDir/BackupPC_tarCreate", @tarArgs);
+ print(LOG $bpc->timeStamp, "can't exec $BinDir/BackupPC_tarCreate\n");
+ # FIX: need to cleanup xfer
+ exit(0);
+ }
+ #
+ # The parent must close the write handle since BackupPC_tarCreate
+ # is using it.
+ #
+ close(WH);