X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=backup.sh;h=652b4636b36b8406a2631b0f2c5f5d234b0a0232;hb=ce562b239bacaeaded0c54f924c9182af9f8ac4a;hp=1f7031ee3937051eb448bd1deeae68414e3e3211;hpb=72dfb4a31cb910cbc221e7910ca1e171991af9dd;p=backup.sh diff --git a/backup.sh b/backup.sh index 1f7031e..652b463 100755 --- a/backup.sh +++ b/backup.sh @@ -20,13 +20,6 @@ # # The script is halfway Norwegian and halfway English. Newer modifications are # in English, we should probably stick to that. -# -# Known issues: -# -# o $R has no proper meaning because of the forking subshell stuff. We need a -# more robust way of returning non-zero on errors, which we probably don't -# right now. -# # The computer to backup. computer=$1 @@ -111,8 +104,8 @@ backup() echo `date`" $computer: Running $TARCMD" >&2 eval $TARCMD > $DATE.idx - if [ -s $TARFILE ]; then - # File is >0 in size, we assume it worked. + if [ $? -eq 0 ] && [ -s $TARFILE ]; then + # File is >0 in size and neither cat or tar tzvf failed; we assume it worked. # Move tar file in place mv $TARFILE $DATE.tgz @@ -143,6 +136,10 @@ backup() # Check that the target filesystem is mounted (actually check that it's not # the root filesystem) + if [ ! -d "$storagedir/$computer" ]; then + echo `date`" $computer: Target filesystem ($storagedir/$computer) does not exist. Aborting" + die + fi rootfilesystem=`df -P /` targetfilesystem=`df -P "$storagedir/$computer"` if [ "$rootfilesystem" == "$targetfilesystem" ]; then