X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_archiveHost;h=bf9a506ea03e37e50c84294f67a86286a82d50f6;hp=34a6e485ef5365ef57ac1650472f42e2377a8249;hb=5b3e6091d542c2e7445d5dd511cdf6e20aec8b8d;hpb=ce708288691ba7dd95a8dac7a468bc0e4c1d6588 diff --git a/bin/BackupPC_archiveHost b/bin/BackupPC_archiveHost index 34a6e48..bf9a506 100755 --- a/bin/BackupPC_archiveHost +++ b/bin/BackupPC_archiveHost @@ -17,9 +17,10 @@ # # AUTHOR # Craig Barratt +# Josh Marshall # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001-2004 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,7 +38,7 @@ # #======================================================================== # -# Version 2.1.0beta0, released 20 Mar 2004. +# Version 3.0.0alpha, released 23 Jan 2006. # # See http://backuppc.sourceforge.net. # @@ -87,6 +88,22 @@ my $mesg = "Writing tar archive for host $host, backup #$bkupNum"; # $share = $bpc->shellEscape($share); $host = $bpc->shellEscape($host); + +# +# We prefer to use /bin/csh because the exit status of a pipeline +# is non-zero if any command is non zero. In contrast, /bin/sh +# and /bin/bash use the convention that the exit status is just +# the exit status of the last command of the pipeline. +# +my @shell; +if ( -x "/bin/csh" ) { + @shell = ("/bin/csh", "-cf"); +} elsif ( -x "/bin/sh" ) { + @shell = ("/bin/sh", "-c"); +} else { + print("Error: Can't find executable /bin/csh or /bin/sh\n"); + exit(1); +} my $cmd = "$tarCreate -t -h $host -n $bkupNum -s $share . "; $cmd .= "| $compPath " if ( $compPath ne "cat" && $compPath ne "" ); if ( -b $outLoc || -c $outLoc || -f $outLoc ) { @@ -101,7 +118,7 @@ if ( -b $outLoc || -c $outLoc || -f $outLoc ) { print("Error: unable to create output directory $outLoc\n"); exit(1); } - if ( $splitSize && -x $splitPath ) { + if ( $splitSize > 0 && -x $splitPath ) { $cmd .= "| $splitPath -b $splitSize - $outLoc/$host.$bkupNum.tar$fileExt."; $mesg .= ", split to output files $outLoc/$host.$bkupNum.tar$fileExt.*"; } else { @@ -114,8 +131,9 @@ print("$mesg\n"); # # Run the command # -my $ret = system($cmd); +my $ret = system(@shell, $cmd); if ( $ret ) { + print("Executing: @shell -cf $cmd\n"); print("Error: $tarCreate, compress or split failed\n"); exit(1); } @@ -125,10 +143,14 @@ if ( $ret ) { # ie: not a tape device). # if ( -d $outLoc && -x $parPath ) { - print("Running $parPath to create parity files\n"); - $ret = system("$parPath a -n $parfile $outLoc/$host.$bkupNum.tar$fileExt.par $outLoc/$host.$bkupNum.tar$fileExt.*"); - if ( $ret ) { - print("Error: $parPath failed\n"); - exit(1); + if ( $parfile != 0 ) { + print("Running $parPath to create parity files\n"); + my $parCmd = "$parPath c -r$parfile $outLoc/$host.$bkupNum.tar$fileExt.par2 $outLoc/$host.$bkupNum.tar$fileExt*"; + $ret = system($parCmd); + if ( $ret ) { + print("Executing: $parCmd\n"); + print("Error: $parPath failed\n"); + exit(1); + } } }